File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes IllegalStateException in servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "IllegalStateException in servlets" Watch "IllegalStateException in servlets" New topic

IllegalStateException in servlets

nilesh bhattad

Joined: Jan 15, 2003
Posts: 8
hi friends,
I'm getting following exception on WebSphere 3.5.2
WebAppInvoker X Unexpected internal engine error while processing request
java.lang.IllegalStateException: ERROR: Cannot set header. Response already committed.
This particlar exception is coming randomly. I'm sure that I'm not updating PrintWriter object after closing. According to Servlet APIs, this exception comes if you use Servlet Redirection. And I'm not using servlet redirection also.
Can u please help me out in this matter? What could be the reason behind this problem? I have some code related to HttpSession in my servlet? Is there any specific care that I have to take while using HttpSession?
Waiting for ur replies.
Thanks and regards
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

either response.sendRedirect or a RequestDispatcher forward command will give this illegal state exception if you've written anything (this includes 'blank' hard returns in JSP's) to the output stream.

you say you haven't redirected, but what about forwarding?
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at .
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in again with a new name which meets the requirements.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
I agree. Here's the link:
subject: IllegalStateException in servlets
It's not a secret anymore!