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
How exactly is the code invoked? Judging from the stacktrace it look like that you're running the Java class with the handle
method using scriptlets inside a JSP file (the inicio2.jsp
to be precise). After that the Java class has written the report to the OutputStream
, the JSP file would continue with outputting the remnant of the file itself (including whitespace!), which would implicitly invoke the getWriter()
to write it to response. Exactly that would cause an IllegalStateException
as you're facing now when the getOutputStream()
is already been called before in the Java class.
It's good that Java code is been placed in a Java class, but that doesn't mean that you may still use JSP to invoke it. The JSP should not contain any single line of Java code. JSP itself is as being a view technology part of the output. To fix this all, just have a Struts action class (or a HttpServlet
) which you can invoke by a HTML or
.