tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andre Van Klaveren <>
Subject Re: Tomcat creating new sessions between Servlet->JSP request dispatch under load
Date Tue, 26 Apr 2005 23:22:19 GMT

You should not be using the Session object to store your DTO for
display.  Especially if you are forwarding the request to a JSP.  The
Session object should only be used to store data that is required to
remain in server memory between client requests.  I would place your
DTO in the Request object instead.  That alone will probably solve
your problem.

Now, assuming you continue to use the Session object, you should
synchronize on the Session object before attempting to add your DTO
object to it.  That will prevent multiple requests from stepping on
each other while trying to add their DTOs to the Session.

I haven't looked at Tomcat's code to see how they implemented the
hashCode method of the Session object but it's not the best way to
determine if two Sessions are equal in your case.  The hash code may
depend on the contents of the Session object.  I would print out the
session ID instead.  This will truely tell you if you have two
different sessions.  From what you describe I find it hard to beleive
that you there is a second session creeping into the picture within
the same request.

Andre Van Klaveren

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message