tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dun...@hyperreal.org
Subject cvs commit: jakarta-tomcat/src/webpages/WEB-INF/classes SnoopServlet.java
Date Fri, 15 Oct 1999 21:31:49 GMT
duncan      99/10/15 14:31:49

  Modified:    .        build.xml
               src/examples/WEB-INF/classes SnoopServlet.java
  Added:       src/webpages/WEB-INF/classes SnoopServlet.java
  Log:
  Restored webpages/WEB-INF/classes/SnoopServlet.java.  Updated
  the servlet for API 2.2 along with the version under examples.
  
  Submitted by:	Jason Hunter, jch@eng.sun.com
  
  Revision  Changes    Path
  1.9       +3 -0      jakarta-tomcat/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/build.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- build.xml	1999/10/15 20:29:06	1.8
  +++ build.xml	1999/10/15 21:31:47	1.9
  @@ -51,6 +51,9 @@
       <javac srcdir="src/examples/WEB-INF/classes"
        destdir="${tomcat.build}/examples/WEB-INF/classes"
        classpath="${tomcat.build}/classes"/>
  +    <javac srcdir="src/webpages/WEB-INF/classes"
  +     destdir="${tomcat.build}/webpages/WEB-INF/classes"
  +     classpath="${tomcat.build}/classes"/>
   
       <javac srcdir="src/examples/jsp/plugin/applet"
        destdir="${tomcat.build}/examples/jsp/plugin/applet"/>
  
  
  
  1.2       +45 -32    jakarta-tomcat/src/examples/WEB-INF/classes/SnoopServlet.java
  
  Index: SnoopServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/examples/WEB-INF/classes/SnoopServlet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SnoopServlet.java	1999/10/09 00:20:00	1.1
  +++ SnoopServlet.java	1999/10/15 21:31:48	1.2
  @@ -1,8 +1,9 @@
  -/* $Id: SnoopServlet.java,v 1.1 1999/10/09 00:20:00 duncan Exp $
  +/* $Id: SnoopServlet.java,v 1.2 1999/10/15 21:31:48 duncan Exp $
    *
    */
   
   import java.io.IOException;
  +import java.io.PrintWriter;
   import java.util.Enumeration;
   import javax.servlet.*;
   import javax.servlet.http.*;
  @@ -11,6 +12,7 @@
    *
    *
    * @author James Duncan Davidson <duncan@eng.sun.com>
  + * @author Jason Hunter <jch@eng.sun.com>
    */
   
   public class SnoopServlet extends HttpServlet {
  @@ -18,21 +20,32 @@
       public void doGet(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException
       {
  -	ServletConfig config = getServletConfig();
  -        ServletOutputStream out = response.getOutputStream();
  +        PrintWriter out = response.getWriter();
  +        response.setContentType("text/plain");
  +
           out.println("Snoop Servlet");
   	out.println();
  -	out.println("Init Parameters");
  -	Enumeration e = config.getInitParameterNames();
  +	out.println("Servlet init parameters:");
  +	Enumeration e = getInitParameterNames();
   	while (e.hasMoreElements()) {
   	    String key = (String)e.nextElement();
  -	    String value = config.getInitParameter(key);
  +	    String value = getInitParameter(key);
   	    out.println("   " + key + " = " + value); 
   	}
   	out.println();
  +
  +	out.println("Context init parameters:");
  +	ServletContext context = getServletContext();
  +	Enumeration enum = context.getInitParameterNames();
  +	while (enum.hasMoreElements()) {
  +	    String key = (String)enum.nextElement();
  +            Object value = context.getInitParameter(key);
  +            out.println("   " + key + " = " + value);
  +	}
  +	out.println();
  +
   	out.println("Context attributes:");
  -	ServletContext context = config.getServletContext();
  -	Enumeration enum = context.getAttributeNames();
  +	enum = context.getAttributeNames();
   	while (enum.hasMoreElements()) {
   	    String key = (String)enum.nextElement();
               Object value = context.getAttribute(key);
  @@ -40,9 +53,7 @@
   	}
   	out.println();
   	
  -	out.println("javax.servlet.Servlet methods");
  -        out.println();
  -        out.println("Attribute names in this request:");
  +        out.println("Request attributes:");
           e = request.getAttributeNames();
           while (e.hasMoreElements()) {
               String key = (String)e.nextElement();
  @@ -50,18 +61,21 @@
               out.println("   " + key + " = " + value);
           }
           out.println();
  +        out.println("Servlet Name: " + getServletName());
           out.println("Protocol: " + request.getProtocol());
           out.println("Scheme: " + request.getScheme());
           out.println("Server Name: " + request.getServerName());
           out.println("Server Port: " + request.getServerPort());
  -        out.println("Server Info: " + getServletConfig().getServletContext().getServerInfo());
  +        out.println("Server Info: " + context.getServerInfo());
           out.println("Remote Addr: " + request.getRemoteAddr());
           out.println("Remote Host: " + request.getRemoteHost());
           out.println("Character Encoding: " + request.getCharacterEncoding());
           out.println("Content Length: " + request.getContentLength());
           out.println("Content Type: "+ request.getContentType());
  +        out.println("Locale: "+ request.getLocale());
  +        out.println("Default Response Buffer: "+ response.getBufferSize());
           out.println();
  -        out.println("Parameter names in this request");
  +        out.println("Parameter names in this request:");
           e = request.getParameterNames();
           while (e.hasMoreElements()) {
               String key = (String)e.nextElement();
  @@ -73,17 +87,15 @@
               out.println();
           }
           out.println();
  -        out.println("javax.servlet.http.HttpServletRequest methods");
  -        out.println();
  -        out.println("Headers in this request");
  +        out.println("Headers in this request:");
           e = request.getHeaderNames();
           while (e.hasMoreElements()) {
               String key = (String)e.nextElement();
               String value = request.getHeader(key);
  -            out.println("   " + key + " : " + value);
  +            out.println("   " + key + ": " + value);
           }
           out.println();  
  -        out.println("Cookies in this request");
  +        out.println("Cookies in this request:");
           Cookie[] cookies = request.getCookies();
           for (int i = 0; i < cookies.length; i++) {
               Cookie cookie = cookies[i];
  @@ -91,32 +103,33 @@
           }
           out.println();
   
  +        out.println("Request Is Secure: " + request.isSecure());
           out.println("Auth Type: " + request.getAuthType());
           out.println("HTTP Method: " + request.getMethod());
  -        out.println("Path Info: " + request.getPathInfo());
  -	out.println("Path Trans: " + request.getPathTranslated());
  -        out.println("Query String: " + request.getQueryString());
           out.println("Remote User: " + request.getRemoteUser());
  -        out.println("Session Id: " + request.getRequestedSessionId());
           out.println("Request URI: " + request.getRequestURI());
  +        out.println("Context Path: " + request.getContextPath());
           out.println("Servlet Path: " + request.getServletPath());
  +        out.println("Path Info: " + request.getPathInfo());
  +	out.println("Path Trans: " + request.getPathTranslated());
  +        out.println("Query String: " + request.getQueryString());
   
           out.println();
  -        out.println("Session Information");
  -        HttpSession session = request.getSession(true);
  -	out.println("Created: " + session.getCreationTime());
  -        out.println("ID: " + session.getId());
  -        out.println("Last Accessed: " + session.getLastAccessedTime());
  -        out.println("Max Inactive Interval: " +
  +        HttpSession session = request.getSession();
  +        out.println("Requested Session Id: " +
  +                    request.getRequestedSessionId());
  +        out.println("Current Session Id: " + session.getId());
  +	out.println("Session Created Time: " + session.getCreationTime());
  +        out.println("Session Last Accessed Time: " +
  +                    session.getLastAccessedTime());
  +        out.println("Session Max Inactive Interval Seconds: " +
                       session.getMaxInactiveInterval());
           out.println();
  -        out.println("Values: ");
  +        out.println("Session values: ");
           Enumeration names = session.getAttributeNames();
           while (names.hasMoreElements()) {
               String name = (String) names.nextElement();
  -            out.println("   " + name + " = " +
  -                        session.getAttribute(name));
  -            out.println();
  +            out.println("   " + name + " = " + session.getAttribute(name));
           }
       }
   }
  
  
  
  1.3       +45 -32    jakarta-tomcat/src/webpages/WEB-INF/classes/SnoopServlet.java
  
  
  
  

Mime
View raw message