1. If the contentDisposition is 'inline',If the PDF file is of bigger sige,the file is not downloading properly, I mean downloaded file contains some binary value like Ċ��c�eF7. But if the contentDisposition is attachement, File is downloading properly.
2. We can see some exception
[2/24/09 18:53:40:362 SGT] 00000027 WebApp E [Servlet Error]-[Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the <param name="inputName"> tag specified for this action.]: java.lang.IllegalArgumentException: Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the <param name="inputName"> tag specified for this action.at org.apache.struts2.dispatcher.StreamResult.doExecute(StreamResult.java:189)
3. In the action,assign your stream data to this inputStream.If you are using jasper or some other API to generate PDF File,Those APIs may return PDF file to output stream.Ofcourse, you can write your PDF file to servlet output stream directly. Doing like this will work but you can see the exception 'response has already been committed'.
I tried with the below 3 steps mentioned below to generate the PDF using the inputStream. But the stream is written to the browser window instead of showing a dialogue box. The browser is displaying the stream data. Can you tell me whether I am missing any thing ?
1.in struts.xml or in respective module's struts configuration file
2. in your action class,define inputStream
3. In the action,assign your stream data to this inputStream.
I am getting the stream from the render() of PD4ML. That stream I had assigned to the inputSteam.
Still data stream is displayed as junk in the browser.
ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Joined: Feb 02, 2011
ok but i am using the Annotaion in my action class.so how can i use param in struts.xml can you please give a sample for that.or any tutorial url .i tried lots of possibilities but i cant get it.
subject: Struts2- Files DownLoad(Streaming) - as inline , attachment