Using PrintWriter and OutputStream

前端 未结 4 1632
不思量自难忘°
不思量自难忘° 2021-01-13 08:33

I am creating a project with struts and I have a problem using Jasper IReports. I want to export some info into a pdf file and I keep getting the java.lang.IllegalStateExcep

4条回答
  •  猫巷女王i
    2021-01-13 08:59

    Some ideas:

    • PrintWriter isn't going to work if you are working with a binary stream (PDF are binary)
    • The illegal state might occur if there is client side timeout or disconnect. A packet trace of the process will tell you a lot (even if you can't read them well). Look at WireShark or what is available for your platform. Its worth your time to learn at least a little bit about what happens at the wire level.
    • Make sure the data you are getting back from the report generate is actually a pdf. Write it to a file and attempt to open.
    • Some situations need you to set the http length header before writing to the stream otherwise they give up when the data starts to show. Might be necessary here.

提交回复
热议问题