File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Help me  to Display multiple Images from Database using Servlets /JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Help me  to Display multiple Images from Database using Servlets /JSP " Watch "Help me  to Display multiple Images from Database using Servlets /JSP " New topic
Author

Help me to Display multiple Images from Database using Servlets /JSP

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi ,

I am displaying a Single Image from DataBase using servlet this way .



This works fine , but could anybody please tell me as in how to display multiple images from Database ??

Thanks .

Save India From Corruption - Anna Hazare.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

each image would be a separate request, hence you'd take the image ID from the request and put it in the SQL query. I'd recommend using a PreparedStatement when using input from the request in SQL to guard against SQL Injection.
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thank you David , for your response .

Currently my requirement is that i have 5 Images in my database , i need to show all of them at once .

So i would modify my sql query as "Select * from Images"
But i am not sure as how to proceed further in this case .

Any help would be greatly appreciated . Thanks .


David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Common mistake: what you want is an HTML page that creates an HTML 'img' tag for each image, then each image results in a separate request to the image servlet and passes the specific ID, then the image servlet responds to each image image request with the image.
The other way would be to send a sing;le request and join the images together, but that is an image manipulation question, not a servlet question
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Unfortunately , I did'nt get you at all .

Why it would be that there would be only 1 Image per one request .

I cant take a better example than this

For example consider a Porno site , which would display Thumb Nails of Images on to the page , when the site clicked on .

So , i want it in that way actually .
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41488
    
  52
It seems you do not have a deep understanding of how the web works. Start by examining the HTML source of a web page that contains multiple images. Then use an HTTP monitor (like the Firefox extension LiveHttpHeaders) to observe how that page is loaded, and in particular, how the HTML is accessed first, and then multiple requests for each of the images is sent. Also be sure to investigate the connection between the IMG tags Dave mentioned and the URLs being accessed on the server. Once you have a handle on all that you're in a position to make progress with the implementation; before that time you will struggle.


Ping & DNS - my free Android networking tools app
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help me to Display multiple Images from Database using Servlets /JSP