tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: IllegalStateException on JSP page
Date Thu, 27 Mar 2003 17:06:03 GMT
On Thu, 27 Mar 2003, Kenny G. Dubuisson, Jr. wrote:

> Date: Thu, 27 Mar 2003 09:43:45 -0600
> From: "Kenny G. Dubuisson, Jr." <kdubuisson@kcmria.com>
> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> Subject: IllegalStateException on JSP page
>
> Hello all.  I've got a simple JSP page which is throwing an
> IllegalStateException when I try to redirect the output to another page.
> Here is a snippet of the code:
>
>          login = login.toUpperCase();
>          Connection myConnection =
>             DriverManager.getConnection(url, login, password);
>          String sessionId = session.getId();
>          Cookie cookie = new Cookie("sessionId", sessionId);
>          response.addCookie(cookie);
>          session.putValue("username", login);
>          session.putValue("password", password);
>          response.sendRedirect("rep_main.jsp");
>          myConnection.close();
>
> I've searched through all the archives and never was able to find a solution
> to this for my case.  One thing I did read was about having to have a
> "web.xml" file for my application (I currently don't have one nor know what
> to put in one).  If you think this is the problem could you forward a
> simple/basic web.xml?  Thanks in advance,
> Kenny
>

Getting an IllegalStateException is exactly what should happen if the
response has already been committed back to the client before this code is
executed.  When the response has been committed (because you've already
written more characters than the size of the response buffer), the HTTP
headers have already been sent -- and it is no longer possible to do a
redirect.

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message