package examples.servlets;
/*
 * @(#)SimpleServlet.java	1.22 97/10/25
 * 
 * Copyright (c) 1996-1997 Sun Microsystems, Inc. All Rights Reserved.
 * 
 * This software is the confidential and proprietary information of Sun
 * Microsystems, Inc. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Sun.
 * 
 * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
 * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
 * THIS SOFTWARE OR ITS DERIVATIVES.
 * 
 * CopyrightVersion 1.0
 */

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 * This is a simple example of an HTTP Servlet.  It responds to the GET
 * and HEAD methods of the HTTP protocol.
 * 
 * @author Adapted from the JSDK2.0 by BEA Systems, Inc. 
 */
public class SimpleServlet extends HttpServlet
{ 
  /**
   * Handle the GET and HEAD methods by building a simple web page.
   * HEAD is just like GET, except that the server returns only the
   * headers (including content length) not the body we write.
   */
  public void doGet (HttpServletRequest	request,
                     HttpServletResponse response) 
       throws ServletException, IOException
  {
    PrintWriter out;
    String title = "Simple Servlet Output";
    
    // You must set the content type and other response header fields first
    response.setContentType("text/html");
    
    // You obtain a handle to the output writer from the HttpServletResponse
    out = response.getWriter();
    
    // Use out to write the data of the response back to the client
    out.println("<HTML><HEAD><TITLE>");
    out.println(title);
    out.println("</TITLE></HEAD><BODY>");
    out.println("<H1>" + title + "</H1>");
    out.println("<P>This is output from SimpleServlet.");
    out.println("</BODY></HTML>");
  }
}
