On Thu, 27 Mar 2003, Kenny G. Dubuisson, Jr. wrote:

> Date: Thu, 27 Mar 2003 09:43:45 -0600
> From: "Kenny G. Dubuisson, Jr." <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: Tomcat Users List <[EMAIL PROTECTED]>
> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to