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

  1. /*
  2.  * @(#)SimpleFormServlet.java    1.22 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. import java.util.*;
  24.  
  25. import javax.servlet.*;
  26. import javax.servlet.http.*;
  27.  
  28. /**
  29.  * This is an example of a simple FormServlet
  30.  */
  31. public class SimpleFormServlet extends HttpServlet { 
  32.  
  33.     public void service(HttpServletRequest req, HttpServletResponse res)
  34.     throws IOException
  35.     {
  36.         Enumeration keys;
  37.         String key;
  38.         String value;
  39.         String title;
  40.  
  41.         res.setContentType("text/html;charset=gb2312");
  42.         ServletOutputStream out = res.getOutputStream();
  43.         out.println("<HEAD><TITLE> SimpleFormServletOutput  </TITLE></HEAD><BODY>");
  44.  
  45.         out.println("<h1> SimpleFormServlet Output </h1>");
  46.         out.println("<P>This is output from SimpleFormServlet.\n");
  47.     keys = req.getParameterNames();
  48.     while (keys.hasMoreElements()) {
  49.         key = (String) keys.nextElement();
  50.         value = req.getParameter(key);
  51.         out.println("<P>" + "key: " + key + " equals value: " + value);
  52.     }
  53.     out.println("</BODY>");
  54.     }
  55.  
  56.     public String getServletInfo() {
  57.         return "A simple form servlet";
  58.     }
  59. }
  60.