Title: RE: ServletSession's and Servlet Reloading
Also,
I want to emphasize that the solution mentioned is not desirable.
Maintaining session information even after reloads promotes rapid
development. It allows one to build up a session and then work on a single
servlet, compiling again and again, without rebuilding the session or using a
'shortcut' servlet to build the session after every reload. Several weeks
ago, someone on this list raised the same issue and they resorted to using their
own session implementation. I think this is largely unecessary since the
Serlvet Container is capable of dealing with this using the standard
spec.
In any
case, how do others deal with this situation? I have been rebuilding the
session using a separate servlet after each recompile of the servlet being
tested. It's tedious and prone to human error and often makes me wish that
I had purchased VAJ and Websphere as twisted as that may
sound.
[Scott
Lawrence]
-Original Message-From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Hani
SuleimanSent: Tuesday, August 08, 2000 10:03 AMTo:
Orion-InterestSubject: RE: ServletSession's and Servlet
Reloading
This behaviour actually makes a lot of sense when you consider
how classloaders work in java. It is impossible to throw away any given class,
in order to do ANY reloading of anything at all, you need to throw away the
classloader, and make a new one and load classes through it. Now, another
factor to throw into the mix is that in order for two classes to be equal,
they must have the same class, AND be loaded through the same classloader.
Hence, when you've reloaded classes, all classes in your session are now
invalid. There is no way around this, I'm afraid! The solution is to ensure
that things are initialised properly in your servlet startup code. Eg, where
you first create the session, make sure you invalidate the existing
one.
-Original Message- From:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Scott Lawrence Sent: Monday, August 07, 2000
11:12 PM To: Orion-Interest Subject: ServletSession's and Servlet Reloading
Orion 1.1.37 (as well as all other versions as far as I
remember) lose the Servlet Session whenever a servlet
is reloaded.
Why is this? Is this an issue with how classloaders are
used? This makes working with complex sessions
very difficult to test and debug since each time I
recompile a servlet, I'll lose the session when that servlet is
reloaded. Other servers do not destroy the session
(Websphere for instance) when reloading
servlets. Have I missed something or is there a setting that
prevents this from happening?