View Javadoc

1   // ========================================================================
2   // Copyright (c) 1996-2009 Mort Bay Consulting Pty. Ltd.
3   // ------------------------------------------------------------------------
4   // All rights reserved. This program and the accompanying materials
5   // are made available under the terms of the Eclipse Public License v1.0
6   // and Apache License v2.0 which accompanies this distribution.
7   // The Eclipse Public License is available at 
8   // http://www.eclipse.org/legal/epl-v10.html
9   // The Apache License v2.0 is available at
10  // http://www.opensource.org/licenses/apache2.0.php
11  // You may elect to redistribute this code under either of these licenses. 
12  // ========================================================================
13  
14  package com.acme;
15  import java.io.IOException;
16  
17  import javax.servlet.ServletConfig;
18  import javax.servlet.ServletException;
19  import javax.servlet.ServletOutputStream;
20  import javax.servlet.http.HttpServlet;
21  import javax.servlet.http.HttpServletRequest;
22  import javax.servlet.http.HttpServletResponse;
23  
24  
25  /* ------------------------------------------------------------ */
26  /** Dump Servlet Request.
27   * 
28   */
29  public class HelloWorld extends HttpServlet
30  {
31      /* ------------------------------------------------------------ */
32      @Override
33      public void init(ServletConfig config) throws ServletException
34      {
35      	super.init(config);
36      }
37  
38      /* ------------------------------------------------------------ */
39      @Override
40      public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
41      {
42          doGet(request, response);
43      }
44  
45      /* ------------------------------------------------------------ */
46      @Override
47      public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
48      {
49          response.setContentType("text/html");
50          ServletOutputStream out = response.getOutputStream();
51          out.println("<html>");
52          out.println("<h1>Hello World</h1>");
53          out.println("</html>");
54          out.flush();
55          
56          try
57          {
58              Thread.sleep(200);
59          }
60          catch (InterruptedException e)
61          {
62              getServletContext().log("exception",e);
63          }
64      }
65  
66      
67   
68      
69  }