Kenny,

I am not sure of my facts here, but I believe that response.sendRedirect() may close the response. If you then attempt to write to the response afterwards, you get an IllegalStateException. Since your code is in a JSP page, this causes problems - after Tomcat has processed the scriptlet, it will continue over the remainder of the page and output it to the client - any HTML tags, new lines or even white space after the end of the scriptlet will be written to the response. This will cause an exception.

As someone has already stated here, this sort of code is much better suited to a Servlet. However, if you are looking for a quick and dirty fix, you could always add this HTML after the scriptlet:

<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<META http-equiv="refresh" content="0; URL=[ENTER PAGE HERE}">
</head>
</html>

This will cause the browser to then request the new page which you specify. This is an awful way to solve the problem, but hopefully it helps...

Ramsay



Kenny G. Dubuisson, Jr. wrote:

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


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



============================================================================
A R K E M E D I A T E C H N O L O G I E S L T D VIEW POINT BASING VIEW BASINGSTOKE HAMPSHIRE RG21 4RG http://www.arkemedia.com mailto:[EMAIL PROTECTED] Tel : +44 1256 869 200 Fax : +44 1256 329 119 ============================================================================
The information in this e-mail and in any attachments is confidential and is intended solely for the attention and use of the named addressee(s). ============================================================================
If you are not the intended recipient, or a person responsible for passing it on to the intended recipient, you are not authorised to hold a copy of this information and you must therefore not disclose, copy, distribute, or retain this message or any part of it. MAILTO:[EMAIL PROTECTED] ============================================================================




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to