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