Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

download report + struts 2

 
aneesh vijayakumar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am using struts 2 in my application. I have to do report download. I am doing the report build in one action and then moving to another page. I need the download option to come when i move to the page after report build.

For the reporting stuff i am using jasper reporting.
I gave like

response.sendRedirect("../../../images/upload/reportDestDir/1GenericReport.pdf");

in the downloadDetailsPage.

In struts i gave like

<action name="download" class="com.trivand.apps.autos.action.***Action" method="downloadReport">
<result name="success">/pages/common/public/downloadDetailsPage.jsp</result>
</action>

But i need to do it like after the action is performed it should go to the downloadDetailsPage and show the download or openwith option..

Please help me out...

Thanks in advance

Aneesh
 
aneesh vijayakumar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have done the download

I did like



Now the download option is working..But there is some error in console like

java.lang.IllegalStateException: getOutputStream() has already been called for this response

It is actually not affecting the result. When i googled it, its given like this is not a critical error.

If anyone has a resolution to it please post here...

Thanks
Anees
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not use the "stream" result type?

http://struts.apache.org/2.x/docs/stream-result.html
 
aneesh vijayakumar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks David for the suggestion

But i am using tiles in my application.

So I gave like

<action name="download" class="com.trivand.apps.autos.action.***Action" method="downloadReport">
<result name="success" type="tiles">***.****.downloadAuto</result>
</action>

Is there any specific advantage of using stream result in downloading?

Thanks
Aneesh
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it writes the result for you, and everything is set from the config. Less code == good.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic