File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes struts2 file download from database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts2 file download from database" Watch "struts2 file download from database" New topic

struts2 file download from database

Rajani Panchumarthy

Joined: Jan 27, 2009
Posts: 22
Could you please help me with the configuration in struts2 for file download.
The following is the scenario that I have:
The database contains the filename, content type and binary stream of the file.

1. The JSP is populated with a list of filenames from database as hyperlink.
1.Click on a filename from JSP.Retrieve the filename in action class from JSP.
2. From the action class, the filename is sent as a parameter to the ejb layer that actually will retrieve the bytes of the corresponsding filename.
3. Show a dialog box to the user either to open the file or save the file in disk.

I have tried to use the following configuration in struts. xml file, but could not achieve the desired result.

Please give your ideas.

The content type that is the database can be of any type, image,pdf,excel,txt,etc

Thank you.
Rajani Panchumarthy

Joined: Jan 27, 2009
Posts: 22
i found the problem, the inputName I have specified is incorrect.I have changed to inputStream and it works.
I agree. Here's the link:
subject: struts2 file download from database
It's not a secret anymore!