home *** CD-ROM | disk | FTP | other *** search
/ Java Developer's Companion / Java Developer's Companion.iso / binaries / Windows / jsdk / servlets / DateServlet.java < prev    next >
Encoding:
Java Source  |  1997-07-18  |  1.6 KB  |  53 lines

  1. /*
  2.  * @(#)DateServlet.java    1.11 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.Date;
  24. import java.util.Hashtable;
  25.  
  26. import javax.servlet.*;
  27. import javax.servlet.http.*;
  28.  
  29. /**
  30.  * Date Servlet
  31.  *
  32.  * This is a simple servlet to demonstrate server-side include
  33.  * It returns a string representation of the current time.
  34.  * @author Scott Atwood
  35.  * @version 1.11, 05/22/97
  36.  */
  37. public class DateServlet extends HttpServlet {
  38.     public void service(HttpServletRequest req, HttpServletResponse res)
  39.     throws ServletException, IOException
  40.     {
  41.         Date today = new Date();
  42.         res.setContentType("text/plain");
  43.  
  44.         ServletOutputStream out = res.getOutputStream();
  45.         out.println(today.toString());
  46.     }
  47.  
  48.     public String getServletInfo() {
  49.         return "Returns a string representation of the current time";
  50.     }
  51.  
  52. }
  53.