473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

how to display multiple images and data in jsp,mysql

please help me ,am using below code.It is only one image display at a time also does not display an data values.how to display multiple images and data values.
Expand|Select|Wrap|Line Numbers
  1.   <% 
  2.         byte[] imgData = null ;
  3.         Class.forName("com.mysql.jdbc.Driver");
  4.         Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/rich","root","");
  5.          Statement stmt = con.createStatement();
  6.           String id = request.getParameter("id"); 
  7.  String name= request.getParameter("name"); 
  8.   String city= request.getParameter("city"); 
  9.    String state = request.getParameter("state"); 
  10.  ResultSet resultset =stmt.executeQuery("select * from publishers where id = '" + id + "' ") ; 
  11.   while(resultset.next())  
  12.   {
  13.       out.println("id:"+id);
  14. out.println("name:"+name);
  15. out.println("city"+city);
  16. out.println("state"+state);
  17.  
  18.       Blob bl = resultset.getBlob(5);
  19. byte[] pict = bl.getBytes(1,(int)bl.length());
  20. response.setContentType("image/jpg");
  21. OutputStream o = response.getOutputStream();
  22. o.write(pict);
  23. o.flush();
  24. o.close();
  25.              }
  26.  
  27.  
  28.  
  29.  
  30.  
  31.         %>
Feb 4 '13 #1
1 6724
Rabbit
12,516 Expert Mod 8TB
Is id a unique field? That is a potential issue if it is because you will only get one row at most.

The main cause of the issue though is that you set the content type to an image. If you want to display multiple images, you will need to send html with image elements. If you want to display data that is not image data, ie these "data values" you mentioned, you can not use the image content type.
Feb 4 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Robert | last post by:
Hi I searching in other groups replay but .... :-( Wy my code (print ("<P> <IMG
5
by: david | last post by:
Can I use WriteFile methods? It seems that it does not work. For example, the following code only dispay one figure. Response.WriteFile("images/image002.jpg") Response.Write("<br><p>")...
2
by: ameshkin | last post by:
I know this is probably not too hard to do, but how do I display multiple rows of a mysql query/recordset. Im having trouble doing this. I don't just want to display them, but I want to make sure...
4
by: Milkstr | last post by:
I want to be able to display the same image a number of times, according to how is set by my database that drives the page. I have database of top goal scorers, i know how to display a list of the...
0
by: Linta | last post by:
Hi, Actually i want to display mutiple images using BinaryWrite method. I am able to store all the images in an object.My problem is that i couldnt display all that images in the browser. I am...
11
by: Jankie | last post by:
I need to dispaly a user's multiple images in one entry.Right now,say if a user uploads 3 images,three entries for the same id display to match 3 images. I only want 1 entry to display all of a...
5
by: swethak | last post by:
Hi,. when i display the image by using below code i got the error as image displayed in the form of garbage value format.plz tell that what's the mistake in my code. <?php...
11
by: nse111 | last post by:
<?php //header('Content-Type: image/jpeg'); header('Content-Type: text/html'); @mysql_connect("localhost","root","dba") or die("Error"); @mysql_select_db("gallery"); $result =...
0
selvasoft
by: selvasoft | last post by:
Hi Please help me any one. I want solution for display multiple images from oracle database.Using JSP. here is my code for display one image from database. Please Any one give me some ideas. ...
1
by: ronnie gordon | last post by:
Hi... I have 4 pics ( jpeg) in an array, but i'm having trouble displaying them all. It never displays all pics, tends to display them in random order, and sometimes pics are repeated 2 or 3 times. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.