473,378 Members | 1,122 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,378 software developers and data experts.

How to display more image from database using JSP

selvasoft
Hi

Please help me i want display all images from my database.
but here my code that will display only one image from database.
But i want all images, any one help me.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title></title>
  4. </head>
  5. <body bgcolor ='#F5F5F5'>
  6. <font face='Bitstream Vera Sans' color='#CD5C5C'>
  7. <form name="Form1"  >
  8. </font>
  9. <%@ page import ="java.sql.*,java.util.*,java.awt.*,java.io.*" %>
  10.  
  11. <%!
  12.  
  13. %>
  14.  
  15. <%!
  16.       String DomainName ="jdbc:oracle:thin:@192.168.251.28:1521:ss";
  17.       String UserName="sss";
  18.       String PassWord="ssss";
  19.  
  20.       private byte[] getReturnInvoiceDetails(String SId)
  21.       {
  22.  
  23.            byte[] image = new byte[300000];
  24.            try
  25.            {
  26.  
  27.                   int n=0;
  28.                   n =System.in.available();
  29.                   image = new byte[n];
  30.                  Image pic =null;
  31.                   Blob blob =null;
  32.  
  33.                   String QS =" Select shadeimg  from ShadeCardSample Where id =26";
  34.  
  35.                    Class.forName("oracle.jdbc.OracleDriver");
  36.                    Connection cn=DriverManager.getConnection(DomainName,UserName,PassWord);  
  37.                    Statement  st=cn.createStatement();
  38.                    ResultSet  rs= st.executeQuery(QS);
  39.  
  40.                    while(rs.next())
  41.                    {
  42.                      image  =rs.getBytes(1);
  43.  
  44.                    }
  45.  
  46.              }
  47.            catch(Exception e)
  48.            {
  49.                System.out.println(e);
  50.            }
  51.  
  52.         return image;
  53.       }
  54. %>
  55.  
  56. <%
  57.  
  58.     String ID =(String)request.getParameter("IMGID");
  59.  
  60.     byte[] Pic = getReturnInvoiceDetails(ID);
  61.     response.setContentType("image/gif");
  62.     OutputStream o =response.getOutputStream();
  63.     o.write(Pic);
  64.     o.flush();
  65.     o.close();
  66.     out.close();    
  67. %>
  68. </form>
  69. <body>
  70. </html>
  71.  
Mar 26 '10 #1
4 8264
jkmyoung
2,057 Expert 2GB
You probably need an Vector of arrays of bytes, eg something like:
Expand|Select|Wrap|Line Numbers
  1. Vector<byte[]> images = new Vector<byte>()
  2.  
  3. ...
  4. while(rs.next()) 
  5.    image = new byte[300000]
  6.    image = rs.getBytes(1); 
  7.    images.add(image);
  8. }
  9.  
and have your display code iterate through the vector similarly.
Mar 26 '10 #2
Hi jkmyoung

Thanks for your idea. I will try that.



-selvasoft
Mar 27 '10 #3
hi jkmyoung

Am try that. But i cant able to find correct solution please give me any one example.








-selvasoft
Mar 31 '10 #4
String QS =" Select shadeimg from ShadeCardSample Where id =26";
above query display only one image and change the query
Aug 23 '13 #5

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

Similar topics

9
by: Wally | last post by:
I am trying to display images from an Access 2000 database and I get an error "Invalid Parameter Used" when I execute the code line "picBLOB.Image = Image.FromStream(stmBLOBData)" in my Visual...
1
by: John Scott | last post by:
I am storing an image in an SQL database and have one field as an image datatype. I am also using a webservice to transport data. I want to be able to resize the image and pass back a thumbnail...
3
by: RAllsopp | last post by:
I have a client who would like to have several pictures associated with one system. I have read about storing only the pathname to save OLE overhead and have set-up a form for my client to...
1
by: Eric Keung | last post by:
Hi all, my case is I want to get an image from access database and I just know it's "OLE object" field type at access I also don't know how to insert it into access here is my code and it just...
5
by: Peter Lapic | last post by:
I have to create a image web service that when it receives an imageid parameter it will return a gif image from a file that has been stored on the server. The client will be an asp.net web page...
3
by: den 2005 | last post by:
Hi everyone, Here is code working on..Trying to insert record with a column with Image or VarBinary datatype in sql database from a existing jpeg image file, then retrieve this image from...
1
by: Objectifnet | last post by:
What I really want to do is to be able to link two pages together using an ID, The table involved displays an image stored on the File Server that has the image details stored in the Database called....
3
by: Dave Keen | last post by:
Hi all. Hope you can help me. This should be easy but I can't make this work. In brief I am building a page of thumbnails using images held in a SQLServer 2000 database. I do this by creating...
7
by: eholz1 | last post by:
Hello Group, Perhaps you can help me. I have a mysql db, that holds images. Images are encoded using base64_decode/encode, etc. Image data seems fine. I have a view.php page that is supposed...
1
by: amritranjan | last post by:
How to retrive image file from MS access database and display this in another JSPpage -------------------------------------------------------------------------------- This is my Jsp code for...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.