Title: RE: Rewritten URL and Forwarding to JSP

Try

    session.invalidate();
    session = null;
    session = request.getSession(true);

Hope this helps.
Sabari

    -----Original Message-----
    From:   E. Tse [SMTP:[EMAIL PROTECTED]]
    Sent:   Wednesday, December 12, 2001 9:59 PM
    To:     [EMAIL PROTECTED]
    Subject:        Rewritten URL and Forwarding to JSP

    Hi,

    I am new to web application development and have a puzzling question.
    I appreciate very much if you can provide some pointers in resolving it.

    In the LoginServlet's doPost() method, after the user is authenticated,
    I invalidate the current session and create a new session.
    Then I do a forward (instead of a redirect) to a JSP using rewritten URL.

      session = request.getSession(false);
      ...
      session.invalidate();
      session = request.getSession(true);
      RequestDispatcher dispatcher = getServletContext().getRequestDispatcher( response.encodeURL(lsURL) );
      dispatcher.forward( request, response );

    The session ID that's encoded to the URL is the old session ID instead of
    the new one.

    I tried to remove all session attributes of the current session instead of
    creating a new one and got a ConcurrentModificationException.

      session = request.getSession(false);
      ...
      Enumeration attrNames = session.getAttributeNames();
      String      attrName  = "";
      while (attrNames.hasMoreElements())
      {
        attrName = (String)attrNames.nextElement();
        session.removeAttribute( attrName );
      }
      RequestDispatcher dispatcher = getServletContext().getRequestDispatcher( response.encodeURL(lsURL) );
      dispatcher.forward( request, response );

    and got:

      java.util.ConcurrentModificationException
            at java.util.HashMap$HashIterator.next(HashMap.java:736)
            at org.apache.catalina.util.Enumerator.nextElement(Enumerator.java:166)

    ___________________________________________________________________________
    To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
    of the message "signoff SERVLET-INTEREST".

    Archives: http://archives.java.sun.com/archives/servlet-interest.html
    Resources: http://java.sun.com/products/servlet/external-resources.html
    LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to