0

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.

Community
  • 1
  • 1
Mac Fly
  • 359
  • 1
  • 7
  • 22

1 Answers1

3

In servlet.

response.setHeader("Content-Disposition",
                     "attachment;filename=downloadname.txt");
Hardik Mishra
  • 14,779
  • 9
  • 61
  • 96