/*
 * @(#)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.
 */
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			s, title = "Simple Servlet Output";
		s = request.getRequestURI();
		System.out.println("GET :"+s);

		// set content type and other response header fields first
        response.setContentType("text/html");

		// then write the data of the response
		out = response.getWriter();

        out.println("<HTML><HEAD><TITLE>");
		out.println(title);
		out.println("</TITLE></HEAD><BODY>");
		out.println("</BODY></HTML>");
		out.close();
	}

    public void doPut (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}

    public void doDelete (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}

    public void dopost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		PrintWriter		out;
		String			title = "Simple Servlet Output";

		// set content type and other response header fields first
        response.setContentType("text/html");

		// then write the data of the response
		out = response.getWriter();

        out.println("<HTML><HEAD><TITLE>");
		out.println(title);
		out.println("</TITLE></HEAD><BODY>");
		out.println("<H1>Simple Form</H1>");
		out.println("<FORM ACTION=\"\">");
		out.println("<TABLE BORDER=0> <TR>");
		out.println("<TD> <P>Your name:</P> </TD>");
		out.println("<TD> <P><INPUT TYPE=text NAME=name SIZE=30></P> </TD>");
		out.println("</TR></TABLE>");
		out.println("</BODY></HTML>");
		out.println("</FORM>");
		out.close();
    }
}
