This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Images in jsp from Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Images in jsp from Servlets " Watch "Images in jsp from Servlets " New topic

Images in jsp from Servlets

Reham Omar

Joined: Sep 06, 2006
Posts: 12
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 ??


Dave Wingate
Ranch Hand

Joined: Mar 26, 2002
Posts: 262
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.

Fun programming etcetera!
I agree. Here's the link:
subject: Images in jsp from Servlets
Similar Threads
View the images as four per row instead of long row that is never ending
insert view, images from mysql database using jsp program
how to use timer for displaying images
Process Blob ResultSet
Displaying images on JSP page