Mac Fly
Mac Fly

Reputation: 397

Download image from servlet by button click i GWT?

I used that code to create the servlet: How to get image with servlet and display it using GWT Image class?
And I used that code to create the button: How to download a file via a button click i GWT?
The mapping to the servlet in my web.xml file is like that:
<servlet-mapping>
<servlet-name>MyImageServlet</servlet-name>
<url-pattern>*.images</url-pattern>
</servlet-mapping>

I give the name of the file with a get parameter "name".
The probleme is, when I click on the button, the files name is always "servlet.images".

How can I do to rename the image with the right name when the user wants to download the image?

Thank you.

Upvotes: 0

Views: 1205

Answers (1)

Hardik Mishra
Hardik Mishra

Reputation: 14887

In servlet.

response.setHeader("Content-Disposition",
                     "attachment;filename=downloadname.txt");

Upvotes: 3

Related Questions