Hosting your own web site - CHAPTER 10 INTRODUCTION TO FILTERING 427 Simple

CHAPTER 10 INTRODUCTION TO FILTERING 427 Simple Filter 2 /index.jsp This new mapping tells the container to apply the audit filter to all resources, and the simple filters only to requests for index.jsp. To make things more interesting, we ll use a different JSP resource to do this test. The FindProd.jsp Listing 10-7 shows the JSP page that will be accessed to test the audit filter. Again, this JSP page is very straightforward. It uses an expression language statement to display the DEPT request parameter value on screen. Listing 10-7. FindProd.jsp

You have submitted as ${param.DEPT} department!

Deploy the FindProd JSP, AuditFilter, and web.xml. Now we re ready to test. Follow these steps: 1. Clear out the Tomcat logs directory. 2. Start Tomcat. 3. Navigate to http://localhost:8080/filters1/FindProd.jsp?DEPT=Engineering. 4. Next, go to http://localhost:8080/filters1/FindProd.jsp?DEPT=Accounting. 5. Open http://localhost:8080/filters1/. 6. Shut down Tomcat. Now, if you examine the log file, you ll see the audit trail left by AuditFilter: 2005-07-27 12:46:24 StandardContext[/filters1]User at IP 127.0.0.1 . (127.0.0.1) accessed resource /filters1/FindProd.jsp and used 1578 ms 2005-07-27 12:46:30 StandardContext[/filters1]User at IP 127.0.0.1 . (127.0.0.1) accessed resource /filters1/FindProd.jsp and used 15 ms 2005-07-27 12:46:36 StandardContext[/filters1]in SimpleFilter 2005-07-27 12:46:36 StandardContext[/filters1]in SimpleFilter2 2005-07-27 12:46:37 StandardContext[/filters1]leaving SimpleFilter2 2005-07-27 12:46:37 StandardContext[/filters1]Getting out of SimpleFilter 2005-07-27 12:46:37 StandardContext[/filters1]User at IP 127.0.0.1 . (127.0.0.1) accessed resource /filters1/ and used 563 ms
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.

Leave a Reply