home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 November / PCONLINE_11_99.ISO / filesbbs / OS2 / APCHSSL2.ZIP / OS2HTTPD / servlets / HelloWorldServlet.java < prev    next >
Encoding:
Java Source  |  1999-03-19  |  1.9 KB  |  59 lines

  1. /*
  2.  * @(#)HelloWorldServlet.java    1.9 97/05/22
  3.  * 
  4.  * Copyright (c) 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.0
  20.  */
  21.  
  22. import java.io.*;
  23.  
  24. import java.util.*;
  25. import javax.servlet.*;
  26. import javax.servlet.http.*;
  27.  
  28. /**
  29.  * Hello World. This servlet simply says hi. 
  30.  *
  31.  * This is useful for testing our servlet admin tool, since
  32.  * this servlet isn't started up by default when Jeeves starts up.
  33.  * Load it by going to http://<server>/admin/servlet.html
  34.  * and giving it the name "hello" and the class "HelloWorldServlet".
  35.  * Then, invoke by using the URL http://<server>/servlet/hello
  36.  */
  37.  
  38. public
  39. class HelloWorldServlet extends HttpServlet {
  40.  
  41.     public void doGet (HttpServletRequest req, HttpServletResponse res)
  42.     throws ServletException, IOException
  43.     {
  44.     res.setContentType("text/html");
  45.  
  46.     ServletOutputStream out = res.getOutputStream();
  47.     out.println("<html>");
  48.     out.println("<head><title>Hello World</title></head>");
  49.     out.println("<body>");
  50.     out.println("<h1>Greetings: Hello World!</h1>");
  51.     out.println("<p>The current date is: " + new Date());
  52.     out.println("</body></html>");
  53.     }
  54.  
  55.     public String getServletInfo() {
  56.     return "Create a page that says <i>Hello World</i> and send it back";
  57.     }
  58. }
  59.