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

method to ouput an image from JSP

 
Joel Karimpil
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need to output an image from a jsp using the outputstream object.

(if there is a better way plz let me know)

this image i am trying to read into an inputstream an store it an bytearrayoutputstream , then sending it .
plz tell me how to do it.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you don't need to...
Use a servlet instead to output the binary data. Far cleaner and easier solution.

And never try to mix different mimetypes in a single response, it just won't work (so don't think you can write a single JSP that returns both the text of your page and the image data).
 
Joel Karimpil
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeroen,

thanks.
but can u tell me how to or refer me to some sample code.
 
Al Petersen
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's some code I use in one application to render a progress bar:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic