File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes pictures in a jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "pictures in a jsp" Watch "pictures in a jsp" New topic

pictures in a jsp

siddharth das
Ranch Hand

Joined: Aug 17, 2007
Posts: 131
i need some idea.
i hava a database with a table.
that table contain two columns,name and picture(gif).
the table is updated daily i.e it contains 'n' number of pictures.
i have to display these pictures in a jsp.
but i have a condition that at a time i display 4 pictures.
so i have to keep page number in the bottom of the page(that is dynamically created according to number of pictures)to display all the pictures.
so how i will do.
please give some idea.
thank you.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

I would start by making a servlet that can stream binary data to a browser.
Have it accept an ID for the image in your database as a form parameter, querystring variable, or part of the URL.

Then write an object that can pull the image data from the database and return it to your servlet for streaming.

Note: Don't try to stream binary data from a JSP.
JSP wasn't meant to do that sort of thing and you'll save yourself a lot of headaches if you start out building it as a servlet.

I have a sample app that covers some of what you'll need to do.
Look for SimpleStream.

It reads the images from file but it wouldn't be difficult to modify it to read from a database instead.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: pictures in a jsp
It's not a secret anymore!