1 on 1 web hosting - } public void destroy( ){ // Remove any
} public void destroy( ){ // Remove any resources to the logging framework herelog( “LoggingFilter destroyed” ); } protected void log( String message ) { getServletContext( ).log(”LoggingFilter: ” + message ); } protected ServletContext getServletContext( ){ return this.servletContext; } } Just as you must be careful with multiple threads in Java servlets, you must be careful not to violate any thread-safety practices with filters. The servlet container may send concurrent threads to a single instance of a filter class, and you must ensure that you don’t do anything to cause problems between the threads. In other words, no client-specific data should be stored in instance variables. Local variables are fine, just as they are in Java servlets, because they are stored on the stack rather than the heap. 15.2.2.2 Declaring the filter in the deployment descriptor The second step in creating a servlet filter is to configure the proper elements in the deployment descriptor for the web application. As you learned in Chapter 4, the name of the deployment descriptor file for a web application is web.xml. The first step in setting up the filter declaration in the web application’s deployment descriptor is to create the actual filter elements. Chapter 4 describes the filter element in detail. The following deployment descriptor fragment illustrates how it looks using the LoggingFilter class from the previous section:
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.