tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Howard Watson" <>
Subject Re: Sudden IllegalStateException
Date Wed, 31 Dec 2003 22:29:07 GMT
>From here:

Why do I get java.lang.IllegalStateException? 
These are the most common reasons how you can get an java.lang.IllegalStateException: 
Calling setBufferSize and content has been written. 
The response has been committed and you do any of the following: 
Calling ServletResponse.reset() or ServletResponse.resetBuffer() 
Calling either HttpServletResponse.sendError() or HttpServletResponse.sendRedirect(). 
Calling RequestDispatcher.forward() which includes performing a jsp:forward 
Calling RequestDispatcher.forward() which includes performing a jsp:forward

I did it the other day like this:

added this line to an existing page - not thinking forced the session to null for testing
if (session null) {send.redirect sessionTimeoutPage}

this code already existed
some more code

sendRedirect to next valid page

added in else and fixed it

>>> 12/31/03 02:54PM >>>
I have been developing a JSP/servlet application using Tomcat 5.0.16.  
Over the past months, I felt that I had learned enough (partially with 
the help of this mailing list) about JSP, servlets, and Tomcat that I 
could debug most of the obsticales that popped up.  Until this morning. 

I  started addnig a new servlet several "levels" down. Suddenly, I 
started getting the following error:


When I launch the application, the Tomcat HTML welcome page redirects 
via a refresh to my login.jsp page via https.  That login page displays 
properly.  When I fill in the login name and password and click on 
submit, I immediately get the above exception.  The line number it 
references is the following:


where Util.MAIN_MENU_PAGE_URL is "/timesheet/mainMenu.jsp", a valid page 

This sendRedirect() is the last thing the login servlet does after 
validating the login and collecting information about the logged in user 
from the database.  This has all been working for months.

The one time I got an illegal state exception before was when I 
accidently did something like session.getAttribute() when the session 
was invalid.  However,  the login servlet starts with

    HttpSession session = request.getSession(true);

which is the ONLY time it's called with a true argument.  I have also 
verified that immediately before the call to sendRedirect(), both the 
session and response variables have reasonable values.

Can any one suggest what I may have changed to suddenly get an illegal 
state exception?

Merrill Cornish

To unsubscribe, e-mail: 
For additional commands, e-mail: 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message