Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic