/Users/lyon/j4p/src/bookExamples/ch30Servlets/Hello.java

1    package bookExamples.ch30Servlets; 
2     
3    import javax.servlet.ServletException; 
4    import javax.servlet.http.HttpServlet; 
5    import javax.servlet.http.HttpServletRequest; 
6    import javax.servlet.http.HttpServletResponse; 
7    import java.io.IOException; 
8    import java.io.PrintWriter; 
9     
10    
11   public class Hello extends HttpServlet { 
12    
13    
14       public void doGet(HttpServletRequest request, 
15                         HttpServletResponse response) 
16               throws IOException, ServletException { 
17           response.setContentType("text/html"); 
18           PrintWriter out = response.getWriter(); 
19    
20           out.println("<html>"); 
21           out.println("<body bgcolor=\"white\">"); 
22           out.println("<head>"); 
23    
24    
25           out.println("<title>" + "Hello This is a servlet" + "</title>"); 
26           out.println("</head>"); 
27           out.println("<body>"); 
28           out.println("This is a <i>test of the Hello </i>servlet<p>"); 
29           out.println("<h1>" + "hello!" + "</h1>"); 
30           out.println("Another fine docjava servlet!!"); 
31           out.println("</body>"); 
32           out.println("</html>"); 
33       } 
34   } 
35    
36    
37    
38