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

Larry Brown, Marty Hall, and Yaakov Chaikin

"Core Servlets and JavaServer Pages, Volume 2"

getInitParameter(param);
if ((value == null) || (value.trim().equals(""))) {
value = null;
}
return value;
}
/** Sets whether the search for the target string
* will be case sensitive.
*/
public void setCaseInsensitive(boolean flag) {
isCaseInsensitive = flag;
}
/** Returns true or false, indicating if the search
* for the target string is case sensitive.
*/
public boolean isCaseInsensitive() {
return(isCaseInsensitive);
}
/** Replaces all strings matching the target string
* with the replacement string.
*/
public String doModification(String orig) {
if ((getTarget() == null) || (getReplacement() == null)) {
return(orig);
} else {
Listing 5.18 ReplaceSiteNameFilter.java (continued)
5.10 Example: A Replacement Filter 243
String target = getTarget();
if (isCaseInsensitive()) {
target = "(?i)" + target;
}
String replacement = getReplacement();
return(orig.replaceAll(target, replacement));
}
}
}
Listing 5.19 web.xml (Excerpt for site name replacement filter)

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">


ReplaceSiteNameFilter

coreservlets.


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