Listeners and Events

Listeners and events for Web applications are another new feature introduced in the Servlet API 2.3 specification. The event-listener model was introduced from JDK 1.1 in the AWT package. You can define a listener for any AWT UI (user interface) element. Any actions or events occurring on the UI element are processed by the AWT listener. The same event-listener model has been incorporated in the servlet specification. Now you can define listeners for two kinds of events:

  • ServletContext events

  • HttpSession events

Depending on the event to be listened to, the listener class has to override the appropriate interface and implement the methods required.

Now look in detail at the two main events.

ServletContext Events

Five events ...

Get Sams Teach Yourself BEA WebLogic Server 7.0™ in 21 Days now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.