SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 95 | Next

Larry Brown, Marty Hall, and Yaakov Chaikin

"Core Servlets and JavaServer Pages, Volume 2"

For example, suppose that the
init or jspInit method looks up constants from a database or ResourceBundle.
In such a case, the default behavior of loading the servlet at the time of the first client
request results in a significant delay for that first client. So, you can use the
load-on-startup subelement of servlet to stipulate that the server load the
servlet when the server first starts. However, a much better approach to this problem
is to place the slow-loading initialization into the ServletContextListener??™s
contextInitialized method. This method is guaranteed to be called by the container
before any other resources are loaded. For more details on listeners, please
see Chapter 6 (The Application Events Framework).
2.7 Declaring Filters
Filters are discussed in detail in Chapter 5 (Servlet and JSP Filters), but the basic
idea is that filters can intercept and modify the request coming into or the response
going out of a servlet or JSP page. Before a servlet or JSP page is executed, the
doFilter method of the first associated filter is executed. When that filter calls
2.7 Declaring Filters 69
doFilter on its FilterChain object, the next filter in the chain is executed. If
there is no other filter, the servlet or JSP page itself is executed. Filters have full
access to the incoming ServletRequest object, so they can check the client??™s hostname,
look for incoming cookies, and so forth.


Pages:
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107