From: "Marco Rolappe" <[EMAIL PROTECTED]>

hi sonny,

<quote>
In order to successfully restore the state of session attributes, all such
attributes MUST implement the java.io.Serializable interface.
...
</quote>

Cool, thanks for confirming what I suspected. It actually makes sense now. :-)



assuming both the shopping cart object and the string object are different session attributes, the situation is as you described: the String class indeed implements Serializable and your shopping cart object's class probably not; so only the String object is persisted.

Yeah, that's got to be it, since I'm not implementing the Serializable interface right now. I will keep that in mind for the future though, if I'm thinking of storing something in the session and persisting it.



regarding "swapped out": PersistentManager (commented out in your config) can persist and restore (i.e. swap out) idle (valid but currently unused) sessions, while tomcat is running.

Oh ok, to save memory by only keeping active sessions in memory. That makes sense.



I know being tired ;-) so here are my (not that tired) thoughts about what to do:

look at the Servlet API docs and investigate the listener interfaces.
there's e.g. a ServletContextListener interface that notifies you about
(servlet/web application) contexts being created and destroyed. there's also
a HttpSessionListener that tells you about sessions being created destroyed
within the respective ServletContext.


- create a HttpSessionListener and configure it in the webapp deployment
descriptor
        - keep track of active sessions

- create a ServletContextListener class and configure it in the webapp
deployment descriptor
        - on shutdown (contextDestroyed()) get the list of active sessions from
your session listener and invalidate them

Solid ideas, Marco. I'm not sure I really want to implement a feature that destroys sessions upon shutdown/restart, but maybe I'll write some invalidator that I can use to facilitate testing.



> -----Urspr�ngliche Nachricht-----
> Von: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Auftrag
> von Sonny Sukumar
> Gesendet: Freitag, 15. August 2003 09:57
> An: [EMAIL PROTECTED]
> Betreff: Re: how to destroy a session?
>
>
>
> Thanks for those quotes, Marco--they were very helpful in understanding
> what's going on. It's still a little confusing though, since my shopping
> cart object doesn't seem to persist at all across shutting
> down/restarting
> Tomcat, but the String object I had in the session does persist. Do you
> think this might have something to do with the String class being
> serializable and the shopping cart I wrote not being
> serializable? I know I
> didn't take any special measures in implementing it to ensure its
> serializability. I think one has to implement a special Java
> interface for
> a class to be serializable, right?
>
> Also, what does it mean for a session to be "swapped out"? I've
> seen that
> phrase before but wasn't sure what it meant.
>
> Lastly, how could one write some code to (using Session.invalidate(),
> presumably) invalidate all active sessions upon Tomcat startup?
> I might be
> missing something simple since I'm pretty tired at the moment,
> but you could
> let me know your thoughts anyway. ;-)
>
> I appreciate your insights,
>
> Sonny
>
> >From: "Marco Rolappe" <[EMAIL PROTECTED]>
> >Reply-To: [EMAIL PROTECTED]
> >To: <[EMAIL PROTECTED]>,<[EMAIL PROTECTED]>
> >Subject: AW: AW: how to destroy a session?
> >Date: Fri, 15 Aug 2003 09:42:49 +0200
> >
> >hi sonny,
> >
> >yes, that's how it works.
> >
> >regarding shuttind down and restarting tomcat (quoting from tomcat docs):
> >
> ><quote>
> >Tomcat provides two standard implementations of Manager for use - the
> >default one stores active sessions, while the optional one stores active
> >sessions that have been swapped out (in addition to saving
> sessions across
> >a
> >restart of Tomcat) in a storage location that is selected via
> the use of an
> >appropriate Store nested element.
> >...
> ></quote>
> >
> >
> ><quote>
> >Restart Persistence
> >
> >Whenver Catalina is shut down normally and restarted, or when an
> >application
> >reload is triggered, the standard Manager implementation will attempt to
> >serialize all currently active sessions to a disk file located via the
> >pathname attribute. All such saved sessions will then be deserialized and
> >activated (assuming they have not expired in the mean time) when the
> >application reload is completed.
> >...
> ></quote>
> >
> >see tomcat tocs (Nested Components/Manager) for details.
> >
> >as a consequence it's probably best to invalidate all active sessions at
> >shutdown/restart, so they're not persisted.
> >
> >
> > > -----Urspr�ngliche Nachricht-----
> > > Von: [EMAIL PROTECTED]
> > >
> [mailto:[EMAIL PROTECTED] Auftrag
> > > von Sonny Sukumar
> > > Gesendet: Donnerstag, 14. August 2003 23:11
> > > An: [EMAIL PROTECTED]
> > > Betreff: Re: AW: how to destroy a session?
> > >
> > >
> > >
> > > Hey Marco,
> > >
> > > Yeah, I now realize that Tomcat wouldn't know if the browser gets
> >closed,
> > > and if one opens a new browser window then the same cookie is still
> >there
> > > that can be sent to Tomcat to carry on the session (that's
> how it works
> > > right?).
> > >
> > > But how come shutting down Tomcat and then restarting it doesn't work
> > > either? I took a look through Tomcat's server.xml and there's a
> > > section for
> > > persisting sections, but it's commented out. It begins:
> > >
> > > <!-- PersistentManager: Uncomment the section below to test Persistent
> > > Sessions..... -->
> > >
> > > You get the idea. As for invalidate(), I'm not looking for a
> > > programmatic
> > > solution right now to destroy sessions...I'm just trying to test
> > > different
> > > test cases with my browser, and so I want to start afresh for
> each test
> > > case. I noticed that one String I stored in the session persists
> > > there even
> > > when I restart Tomcat and that's the thing that's baffling me.
> > >
> > > Sonny
> > >
> > > >From: "Marco Rolappe" <[EMAIL PROTECTED]>
> > > >Reply-To: [EMAIL PROTECTED]
> > > >To: <[EMAIL PROTECTED]>,<[EMAIL PROTECTED]>
> > > >Subject: AW: how to destroy a session?
> > > >Date: Thu, 14 Aug 2003 22:37:19 +0200
> > > >
> > > >hi sonny,
> > > >
> > > >to invalidate a session use the session's metho invalidate ().
> > > just closing
> > > >the browser window won't do the trick (how should tomcat
> know?). AFAIR
> > > >tomcat can serialize/persist sessions, but that depends on the
> > > >configuration, I guess.
> > > >
> > > >so just invalidate() your sessions and your problem should be gone.
> > > >
> > > > > -----Urspr�ngliche Nachricht-----
> > > > > Von: [EMAIL PROTECTED]
> > > > >
> > >
> [mailto:[EMAIL PROTECTED] Auftrag
> > > > > von Sonny Sukumar
> > > > > Gesendet: Donnerstag, 14. August 2003 21:33
> > > > > An: [EMAIL PROTECTED]
> > > > > Betreff: how to destroy a session?
> > > > >
> > > > >
> > > > >
> > > > > Hi guys,
> > > > >
> > > > > How does a session get destroyed exactly? I set my sessions
> > > to timeout
> > > > > after 4 hours by configuring my web.xml file, but I thought
> > > that either
> > > > > closing the browser window or restarting Tomcat would do
> the trick.
> > > > >
> > > > > The shopping cart object in my session is destroyed, but there's a
> > > >String
> > > > > that somehow survives even when I both close the browser and
> > > > > restart Tomcat.
> > > > >
> > > > > Btw, I'm running Tomcat 4.1.12 and Cocoon 2.0.4, in case
> it matters.
> > > > >
> > > > > Thanks,
> > > > >
> > > > > Sonny
> > > > >
> > > > > _________________________________________________________________
> > > > > MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
> > > > > http://join.msn.com/?page=features/virus
> > > > >
> > > > >
> > > > >
> >---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > > >
> > > >
> > > >
> > > >---------------------------------------------------------------------
> > > >To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > >For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > >
> > > _________________________________________________________________
> > > MSN 8 with e-mail virus protection service: 2 months FREE*
> > > http://join.msn.com/?page=features/virus
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
> _________________________________________________________________
> The new MSN 8: advanced junk mail protection and 2 months FREE*
> http://join.msn.com/?page=features/junkmail
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>



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


_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus



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



Reply via email to