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 249 | Next

Larry Brown, Marty Hall, and Yaakov Chaikin

"Core Servlets and JavaServer Pages, Volume 2"

After printing
the report, the filter calls the doFilter method of the Filter-
Chain to invoke the servlet or JSP page (or the next filter in the chain,
if there is one).
4. Registration with the Web application home page and the
servlet that displays the daily special. First, the filter element
associates the name Reporter with the class coreservlets.
filters.ReportFilter. Then, the filter-mapping element
uses a url-pattern of /index.jsp to associate the filter with
the home page. Finally, the filter-mapping element uses a
servlet-name of TodaysSpecial to associate the filter with the
daily special servlet (the name TodaysSpecial is declared in the
servlet element). See Listing 5.3.
5. Disablement of the invoker servlet. First, we create NoInvoker-
Servlet (Listing 5.6) that generates an error message stating that the
invoker servlet has been disabled. Next, we use the servlet and
servlet-mapping elements (Listing 5.3) to specify that all URLs
that begin with http://host/webAppPrefix/servlet/ should invoke the
NoInvokerServlet.
Given these settings, the filter is invoked each time a client requests the Web
application home page (Listing 5.4 and Figure 5??“1) or the daily special servlet (Listing
5.5 and Figure 5??“2).
5.2 Example: A Reporting Filter 211
Listing 5.2 ReportFilter.java
package coreservlets.filters;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.


Pages:
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261