The moose likes Struts and the fly likes download file in struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "download file in struts2" Watch "download file in struts2" New topic

download file in struts2

zheng li
Ranch Hand

Joined: Jun 16, 2009
Posts: 56
does anyone here have experieces with stream result type?
please help




if i use "link download", everything is ok except a new window always pops up.
if i use "button download", a download confirm dialog pops up and asks me what i want to do----open, save, or cancel, so far so good.
but if i choose open, another confirm dialog will pop up, and i need to click open again to open the file. (BTW: save and cancel work just fine.)
i have been working on this for 4 hours and have no clue.
please help.
thanks in advance.

and another question about stream result type.
what if the content for download is not from a file by constructed dynamically, do i need to create a file for it?
zheng li
Ranch Hand

Joined: Jun 16, 2009
Posts: 56
struts.xml is wrong,
below is the right one

is there anyone who has the same problem?
zheng li
Ranch Hand

Joined: Jun 16, 2009
Posts: 56
seems i should use get but not post to download a file
I agree. Here's the link: http://aspose.com/file-tools
subject: download file in struts2
Similar Threads
struts2 file download from database
Why isn't my code Opening a Saved file?
problem in file downloading in struts 2.0
Browser gets refreshed after file download in Struts2
Delete file when the file downloaded.