| Author |
Context Listener
|
Neeraj Vij
Ranch Hand
Joined: Nov 25, 2003
Posts: 315
|
|
Hi, How can we use context listener in real-time applications. Regards, Neeraj.
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Does your app have anything that needs to be initialized at startup? Does it have anything that needs to be cleaned up at shutdown? If so, a ContextListener is just the thing for you.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Neeraj Vij
Ranch Hand
Joined: Nov 25, 2003
Posts: 315
|
|
Hi Ben, Thanx for the reply...I justed wanted for improving my knowledge. Can u provide some scenario, where u have used context-listner. In books I have read for db connections etc. but not satisfied with them.. Regards, Neeraj.
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
True not too many people would make a DB connection in a listener. It would make sense, however to initialize a connection pool from a listener. You may also have initialization data that is stored in a database that you want to retrieve and cache when the context initializes. I have a webservice app that communicates with a non-browser application. In it there is a login handshake that gives the client an ID string (similar to a JSPSessionID). I have an in-memory object that keeps track of who's logged in and when their session expires. So that I can restart the application without throwing all of these clients out, I serialize that object to disk when the context is destroyed and de-serialize it when the context starts back up.
|
 |
Neeraj Vij
Ranch Hand
Joined: Nov 25, 2003
Posts: 315
|
|
Hi, thnx Ben for all your inputs. Regards, Neeraj.
|
 |
 |
|
|
subject: Context Listener
|
|
|