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 Struts 2.2 jasper report filename issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2.2 jasper report filename issue" Watch "Struts 2.2 jasper report filename issue" New topic
Author

Struts 2.2 jasper report filename issue

V. Oliver Smith
Greenhorn

Joined: Nov 15, 2011
Posts: 11
I am using struts2-jasperreports-plugin-2.2.3.1 and I'm having a problem getting a correct filename to display when clicking "save as". The default filename that is displayed when the dialog first appears is the name of the action. I have the following in my struts.xml file:

<global-results>
<result name="pdf" type="jasper">
<param name="location">/reports/${jasperRpt}</param>
<param name="dataSource">jasperRptData</param>
<param name="format">PDF</param>
<param name="reportParameters">jasperRptParams</param>
<param name="documentName">jasperRptFileName</param>
</result>
<result name="xls" type="jasper">
<param name="location">/reports/${jasperRpt}</param>
<param name="dataSource">jasperRptData</param>
<param name="format">XLS</param>
<param name="documentName">jasperRptFileName</param>
<param name="reportParameters">jasperRptParams</param>
</result>
</global-results>

Following the API javadoc, when the output response stream is written, Content-disposition was set with "inline;filename=jasperRptFilename.pdf", which should result in jasperRptFilename.pdf appearing as the default name when the save dialog appears. Rather, the name of the action is shown. I've included an attachment, which shows the name of the action, generateStandardReport.pdf, as the default display name.

Also, "Struts Problem Report" appears as the tab title for the report. I turned the log4j information level to DEBUG, and didn't see one Exception in the log file, so I don't know where that is coming from, and if it's involved in the issue at hand. I've also included an attachment showing that as well.

Any assistance will be GREATLY appreciated. By the way, I'm using jasperreports-4.1.3, along with it's associated dependent jars.


[Thumbnail for report_data_display.JPG]

[Thumbnail for report_save_dialog.JPG]

Nitin Surana
Ranch Hand

Joined: Jan 21, 2011
Posts: 129

Here's a complete working example on Struts2 Jasper Reports.

http://www.onlinexamples.com/showfullexample.action?idexamples=20&title=Jasper%20Report%20Example
V. Oliver Smith
Greenhorn

Joined: Nov 15, 2011
Posts: 11
Nitin,

thanks so much. The key wasn't changing the code to match your example. it was to add

<param name="contentDisposition">attachment</param>

Now everything is "copasetic" (smile)

Thanks again
 
wood burning stoves
 
subject: Struts 2.2 jasper report filename issue