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

Larry Brown, Marty Hall, and Yaakov Chaikin

"Core Servlets and JavaServer Pages, Volume 2"

0 " +
"Transitional//EN\">\n";
out.println
(docType +
"\n" +
"Today's Special\n" +
"\n" +
"
\n" +
"

Today's Special: " + title + "s!

\n" +
"" ALT=\"" + title + "\">\n" +
"
\n" +
"Special deal: for only twice the price, you can\n" +
"buy one, get one free!.\n" +
"");
}
// Rotate among the three available filter images.
private void updateSpecials() {
double num = Math.random();
if (num < 0.333) {
title = "Air Filter";
picture = "air-filter.jpg";
} else if (num < 0.666) {
title = "Coffee Filter";
picture = "coffee-filter.gif";
} else {
title = "Pump Filter";
picture = "pump-filter.jpg";
}
}
}
Chapter 5 ?–  Servlet and JSP Filters 216
Listing 5.6 NoInvokerServlet.java
package coreservlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
/** Simple servlet used to give error messages to
* users who try to access default servlet URLs
* (i.e., http://host/webAppPrefix/servlet/ServletName)
* in Web applications that have disabled this
* behavior.
*/
public class NoInvokerServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String docType =
"

Pages:
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265