- Posted by: chandrasekar ramaswamy
- Posted on: January 20 2004 08:19 EST
Are the Session listener events synchronous or asynchronous??.
Can the Listener event class be used to interact with the database.
For example, when i set an attribute to a session, the container will invoke the attributeAdded method of the listener class. Now i want to store the session data in a database.
can this process of saving to the DB be done inside the attributeAdded method of the listener. is this a proper design.
Also do the container call the listener's method from the same thread of execution of the client. (i.e) a request will have a thread to access the servlet. If we set a value in session, the container has to invoke the listener. So does the container do this within the same thread or it uses different threads to invoke the listeners asynchronously??
Thanks in advance,
- Question on Session Listeners in servlets by Paul Strack on January 20 2004 09:40 EST
1. Can the Listener event class be used to interact with the database?
Sure. The Listener event class can do just about anything. It is kind of an unusual design to perform database updates for "attributeAdded" events, though.
2. Are the Session listener events synchronous or asynchronous?
The specifications are vague. I believe in practice they tend to be synchronous, but this is not something you can count on.
what is the good design methodology to keep the session persistent
even after system crash / restart using listeners??
> what is the good design methodology to keep the session persistent
> even after system crash / restart using listeners??
Iam really looking for a good design pattern to achieve this. Has someone done this in their applications.
If the server crashes, odds are very good that you session listeners are going to fail as well.
If you have any data that you don't want to lose, store that data in the database, not in the session. That is the only way to be 100% safe.