Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
90
Chapter 3 Handling the Client Request: Form Data
Listing 3.9 BadCodeServlet.java (continued)
"if (a
" doThis();\n" +
"} else {\n" +
" doThat();\n" +
"}\n";
public String getCodeFragment() {
return(codeFragment);
}
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String title = "The Java if Statement";
out.println(ServletUtilities.headWithTitle(title) +
"\n" +
"" + title + "
\n" +
"\n" +
getCodeFragment() +
"
\n" +
"Note that you must use curly braces\n" +
"when the if or else clauses contain\n" +
"more than one expression.\n" +
"