This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
No, those are not the problem. Neither System.out.println or e.printStackTrace write to the output stream, so they will not cause the exception you see. Something else is writing to or committing the response before the call to forward().
there is no problem in calling System.out.println() or e.printStackTrace as they all perform the operation on the Web Server(which hosts the servlet) itself. The IllegalStateException will be thrown if there's any response being committed to the client's browser before forwarding or redirecting.
What I suppose you want to do is the client to download a file as well as see a page. Usually this is implemented using Client-Pull mechanism in which the user sees a page and then the download starts. What you want to achieve can also be done using Server push mechanism (although I've never tried it so not sure). You can do this using a library class like com.oreilly.servlet.MultipartResponse
I am facing the same issue. (2 responses...one is commited and another is in forwarded), How did you make it to work? Did you use client pull mechanism, did it work for you, can you please send me the same code!