File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes downloading a File in Struts 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "downloading a File in Struts 2" Watch "downloading a File in Struts 2" New topic
Author

downloading a File in Struts 2

Neeraj jain
Ranch Hand

Joined: Jun 18, 2013
Posts: 104
I am trying to download a file with Struts2 but when i click on the hyperlink to download the file i am getting
No result defined for action com.mkyong.common.action.DownloadAction and result success

here is the code
struts.xml


downloadPage.jsp



DownloadAction




Anyone please help me why the file isn't downloading
Ashwini Kashyap
Ranch Hand

Joined: Aug 30, 2012
Posts: 90
You have missed mapping "download" action in struts.xml file.
Hence it isn't able to download it. Hope this helps.

Thanks,
Ashwini Kashyap | www.infocepts.com
Neeraj jain
Ranch Hand

Joined: Jun 18, 2013
Posts: 104
thanks bro but i am returning success from execute method so why i have to do the mapping of download
Ashwini Kashyap
Ranch Hand

Joined: Aug 30, 2012
Posts: 90
i am returning success from execute method so why i have to do the mapping of download


Success will get executed only when your "download" action class will get called and you haven't mapped that action and hence it wont go into your class and execute further.

Your code should be like -

<action name="download" class=".....">
<result name="success" type="stream">
.......

instead of
<action name="success" class=".....">
<result name="success" type="stream">
.......


Regards,
Ashwini
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: downloading a File in Struts 2