home *** CD-ROM | disk | FTP | other *** search
/ Java Developer's Companion / Java Developer's Companion.iso / binaries / Windows / jsdk / servlets / HelloWorldServlet.java < prev    next >
Encoding:
Java Source  |  1997-07-18  |  1.8 KB  |  57 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 javax.servlet.*;
  25. import javax.servlet.http.*;
  26.  
  27. /**
  28.  * Hello World. This servlet simply says hi. 
  29.  *
  30.  * This is useful for testing our servlet admin tool, since
  31.  * this servlet isn't started up by default when Jeeves starts up.
  32.  * Load it by going to http://<server>/admin/servlet.html
  33.  * and giving it the name "hello" and the class "HelloWorldServlet".
  34.  * Then, invoke by using the URL http://<server>/servlet/hello
  35.  */
  36.  
  37. public
  38. class HelloWorldServlet extends HttpServlet {
  39.  
  40.     public void doGet (HttpServletRequest req, HttpServletResponse res)
  41.     throws ServletException, IOException
  42.     {
  43.     res.setContentType("text/html");
  44.  
  45.     ServletOutputStream out = res.getOutputStream();
  46.     out.println("<html>");
  47.     out.println("<head><title>Hello World</title></head>");
  48.     out.println("<body>");
  49.     out.println("<h1>Hello World</h1>");
  50.     out.println("</body></html>");
  51.     }
  52.  
  53.     public String getServletInfo() {
  54.     return "Create a page that says <i>Hello World</i> and send it back";
  55.     }
  56. }
  57.