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
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.