• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to download an image in jsp

 
Santhana Lakshmi.S
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
In my project im displaying images in a page.
I made all the images as a link.
Now i want while clicking those images the imgaes has to be downlaoded that is the open with r save to disk dialogue box to be opened.
can anyone tell me how to do this
thanx a lot
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With any file, if you want to force an Open/Save dialog box in the browser, you would have to set the content type and content disposition headers to some value that the browser doesn't understand (more specifically, something that the browser hasn't been configured to work with). You would then need to stream the file to the browser.

JSPs were not meant to stream binary data so getting them to do so is difficult at best. Servlets, on the other hand, do this quite easily.
I've published a sample app with code for streaming images to browsers.
http://simple.souther.us
Look for SimpleStream
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!