JSPs should never be used to serve non-text data. Please see this article to find out why.
Rather, a servlet -- possibly using the help of other classess -- should be used to get the image data and serve it as the response. Be sure to set the appropriate response headers accordingly.
In your HTML page -- whether it's generated from JSP or not is moot -- you would use an <img> tag just like any other image. Except that the src attribute of the <img> tag references the image-serving servlet rather than an image file.
That's the idea, but that article is 7 years old and shows it. Statements like "you could do the database access in the JSP itself" have no place in modern architectures.
Remko Strating
Ranch Hand
Joined: Dec 28, 2006
Posts: 893
posted
0
Bear Bibeault thanks for your reply
I understand all my database access is done at one helper class.
I will use this idea for making a utility servlet which will retrieve the images for the different jsp's.
Thanks for your input.
Dilshan Edirisuriya
Ranch Hand
Joined: Apr 22, 2006
Posts: 299
posted
0
I also face the same problem. I want to display these images as thumbnails dats means i want to show dat by reducing it size, height and width.
Originally posted by Dilshan Edirisuriya: I also face the same problem. I want to display these images as thumbnails dats means i want to show dat by reducing it size, height and width.
Also, if you want to see an example app that uses a servlet to stream images to a browser, I have one on my site. http://simple.souther.us Look for Simple Stream.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.