Sample Program: Writing Listeners for the BookShoppingServlet
Now you will create an example listener for your BookShoppingServlet. You will be writing listeners for both the events of this servlet: the ServletContext event and the HttpSession event. The methods that you implement in the listeners will not have any functionality; you will simply print messages out on the console through them.
Look first at the source code in Listing 4.4 for the ServletContext listener first.
Listing 4.4. DemonstrateContextListener.java
/****************************************************************************** * Class Name:DemonstrateContextListener * Implements:ServletContextListener * Description:Servlet to demonstrate Servlet Context Listener functionality ... |
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.