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

Larry Brown, Marty Hall, and Yaakov Chaikin

"Core Servlets and JavaServer Pages, Volume 2"


*/
private void addContextEntry(ServletContext context,
String initParamName) {
ArrayList paramValues = new ArrayList();
String attributeNames =
context.getInitParameter(initParamName);
if (attributeNames != null) {
String[] params = attributeNames.split("\\s++");
for (String value : params) {
paramValues.add(value);
}
context.setAttribute(initParamName, paramValues);
}
}
/** Returns a string containing the daily special
* names. For insertion inside an HTML text area.
*/
public static String dailySpecials(ServletContext context) {
String attributeName = "daily-special-item-names";
ArrayList itemNames =
(ArrayList)context.getAttribute(attributeName);
Listing 6.37 DailySpecialRegistrar.java (continued)
Chapter 6 ?–  The Application Events Framework 328
String itemString = "";
for(int i=0; iitemString = itemString + (String)itemNames.get(i) + "\n";
}
return(itemString);
}
/** Returns a UL list containing the daily special
* names. For insertion within the body of a JSP page.
*/
public static String specialsList(ServletContext context) {
String attributeName = "daily-special-item-names";
ArrayList itemNames =
(ArrayList)context.getAttribute(attributeName);
String itemString = "
    \n";
    for(int i=0; iitemString = itemString + "
  • " +
    (String)itemNames.get(i) + "\n";
    }
    itemString = itemString + "
";
return(itemString);
}
}
Listing 6.


Pages:
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382