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

Images in jsp from Servlets

 
Reham Omar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I have an application where i should display images from the Database to the jsp. Maybe more than one image per page. The thing is I do store the image in the DB not only the path. But I do not know how to add it to the jsp. for example when i query the database on anything i set the session.attribute() with watever things i want to display in the jsp, but how to set the session with an image to load it latter ??

Thanks

Reham
 
Dave Wingate
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An often-used strategy is to have your JSP include and image tag like:

<img src="ImageServlet?imageid=1234">

To use that strategy you'll have to write a Servlet capable of returning image content. You can see the skeletal outline of such a servlet in this previous post.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic