• Post Reply Bookmark Topic Watch Topic
  • New Topic

Showing image files from a file system in a JSP

 
Jerome Josephraj
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to display images in a jsp. These images are stored in a file system.
What is the best way to go about it?
TIA.
 
chanoch wiggers
Author
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
search on the web for the answer, or even search on previous questions - this question is the most often asked question on jsp forums.
in short, the answer is use a servlet instead if you can, its not good practice to do it from jsp since jsps are for character data and images are binary. in short the answer is:
set the mime type of the response as image/gif or whatever with setContentType()
and then get the output stream adn stream the image as an array of bytes.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!