tags:

views:

60

answers:

2

The problem is simple, I don't know if has a simple solution: I'm using JPA to persist images to a database. I'm also using Struts 2.

I wrote an action that take the image from the db and sand it to the client.

The problem is that in this way, when people try to download the image on their PC, they have to write a name for the file (default is something like image.action - always the same).

Thanks

+3  A: 

Check out the Content-Disposition HTTP Header to specify the filename of the resource. For example:

Content-Disposition: inline; filename: file.jpg

You can add this to your HttpServletResponse like so:

response.setHeader("Content-Disposition", "inline; filename: file.jpg");
krock
GREAT! It works! :)
s.susini
A: 

There is another simple way to do this, all you have to do is to setup StreamResult in strut.xml

More detail, reference this page

Truong Ha