FileDocCategorySizeDatePackage
BrokenServlet.javaAPI DocExample3622Sun Apr 25 16:05:20 BST 2004None

BrokenServlet

public class BrokenServlet extends HttpServlet

Fields Summary
protected PrintWriter
out
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Called in response to a GET request (data encoded in the URL)

		response.setContentType("text/html");

		out = response.getWriter(); 

		// Simulate a database lookup
		int result = 42;

		print(result);

	
protected voidprint(int result)

		out.println("<!DOCTYPE html PUBLIC " +
			"\"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" +
			"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"\n" +
			">");
		out.println("<html>");
		out.println("<head><title>Servlet Output</title></head>");
		out.println("<body>");

		out.println("<h1>Results</h1>");
		out.println("<p>The result is " + result + "</p>");

		out.println("</body>");
		out.println("</html>");
		out.close();