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

Larry Brown, Marty Hall, and Yaakov Chaikin

"Core Servlets and JavaServer Pages, Volume 2"

com.
First, the filter element of web.xml (Listing 5.19) associates the
name ReplaceSiteNameFilter with the class coreservlets.
filters.ReplaceSiteNameFilter, specifying two init parameters:
target and replacement. Next, the filter-mapping
element uses a url-pattern of /plugSite/page2.jsp (see
Listing 5.20) so that the filter fires each time that JSP page is requested.
4. Disablement of the invoker servlet. This operation is shown in
Section 5.2 (Example: A Reporting Filter) and is not repeated here.
Figure 5??“7 A page that promotes
the filtersRus.com site.
5.10 Example: A Replacement Filter 241
Figure 5??“8 The page that promotes the filtersRus.com site after its output is modified
by the ReplaceSiteNameFilter.
Listing 5.18 ReplaceSiteNameFilter.java
package coreservlets.filters;
/** Filter that replaces all occurrences of the target
* string with the replacement string. The target and
* replacement strings are provided as init parameters
* to the filter in the web.xml file.
*/
public class ReplaceSiteNameFilter extends ModificationFilter {
private boolean isCaseInsensitive = false;
Chapter 5 ?–  Servlet and JSP Filters 242
/** The string that needs replacement.
*/
public String getTarget() {
return getInitParameter("target");
}
/** The string that replaces the target.
*/
public String getReplacement() {
return getInitParameter("replacement");
}
/** Returns the init parameter value specified by 'param' or
* null if it is not present or an empty string
*/
private String getInitParameter(String param) {
String value = config.


Pages:
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293