• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2.2 jasper report filename issue

 
V. Oliver Smith
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
report_data_display.JPG
[Thumbnail for report_data_display.JPG]
report_save_dialog.JPG
[Thumbnail for report_save_dialog.JPG]
 
Nitin Surana
Ranch Hand
Posts: 129
Java Netbeans IDE Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic