s.susini
s.susini

Reputation: 601

Struts2 dynamic action names

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

Upvotes: 1

Views: 834

Answers (2)

Truong Ha
Truong Ha

Reputation: 10954

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

Upvotes: 1

krock
krock

Reputation: 29619

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");

Upvotes: 3

Related Questions