Source Code Cross Referenced for RequestDumperValve.java in  » Sevlet-Container » apache-tomcat-6.0.14 » org » apache » catalina » valves » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Sevlet Container » apache tomcat 6.0.14 » org.apache.catalina.valves 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.catalina.valves;
019:
020:        import java.io.IOException;
021:        import java.util.Enumeration;
022:
023:        import javax.servlet.ServletException;
024:        import javax.servlet.http.Cookie;
025:
026:        import org.apache.catalina.connector.Request;
027:        import org.apache.catalina.connector.Response;
028:        import org.apache.catalina.util.StringManager;
029:        import org.apache.juli.logging.Log;
030:
031:        /**
032:         * <p>Implementation of a Valve that logs interesting contents from the
033:         * specified Request (before processing) and the corresponding Response
034:         * (after processing).  It is especially useful in debugging problems
035:         * related to headers and cookies.</p>
036:         *
037:         * <p>This Valve may be attached to any Container, depending on the granularity
038:         * of the logging you wish to perform.</p>
039:         *
040:         * @author Craig R. McClanahan
041:         * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
042:         */
043:
044:        public class RequestDumperValve extends ValveBase {
045:
046:            // ----------------------------------------------------- Instance Variables
047:
048:            /**
049:             * The descriptive information related to this implementation.
050:             */
051:            private static final String info = "org.apache.catalina.valves.RequestDumperValve/1.0";
052:
053:            /**
054:             * The StringManager for this package.
055:             */
056:            protected static StringManager sm = StringManager
057:                    .getManager(Constants.Package);
058:
059:            // ------------------------------------------------------------- Properties
060:
061:            /**
062:             * Return descriptive information about this Valve implementation.
063:             */
064:            public String getInfo() {
065:
066:                return (info);
067:
068:            }
069:
070:            // --------------------------------------------------------- Public Methods
071:
072:            /**
073:             * Log the interesting request parameters, invoke the next Valve in the
074:             * sequence, and log the interesting response parameters.
075:             *
076:             * @param request The servlet request to be processed
077:             * @param response The servlet response to be created
078:             *
079:             * @exception IOException if an input/output error occurs
080:             * @exception ServletException if a servlet error occurs
081:             */
082:            public void invoke(Request request, Response response)
083:                    throws IOException, ServletException {
084:
085:                Log log = container.getLogger();
086:
087:                // Log pre-service information
088:                log.info("REQUEST URI       =" + request.getRequestURI());
089:                log.info("          authType=" + request.getAuthType());
090:                log
091:                        .info(" characterEncoding="
092:                                + request.getCharacterEncoding());
093:                log.info("     contentLength=" + request.getContentLength());
094:                log.info("       contentType=" + request.getContentType());
095:                log.info("       contextPath=" + request.getContextPath());
096:                Cookie cookies[] = request.getCookies();
097:                if (cookies != null) {
098:                    for (int i = 0; i < cookies.length; i++)
099:                        log.info("            cookie=" + cookies[i].getName()
100:                                + "=" + cookies[i].getValue());
101:                }
102:                Enumeration hnames = request.getHeaderNames();
103:                while (hnames.hasMoreElements()) {
104:                    String hname = (String) hnames.nextElement();
105:                    Enumeration hvalues = request.getHeaders(hname);
106:                    while (hvalues.hasMoreElements()) {
107:                        String hvalue = (String) hvalues.nextElement();
108:                        log.info("            header=" + hname + "=" + hvalue);
109:                    }
110:                }
111:                log.info("            locale=" + request.getLocale());
112:                log.info("            method=" + request.getMethod());
113:                Enumeration pnames = request.getParameterNames();
114:                while (pnames.hasMoreElements()) {
115:                    String pname = (String) pnames.nextElement();
116:                    String pvalues[] = request.getParameterValues(pname);
117:                    StringBuffer result = new StringBuffer(pname);
118:                    result.append('=');
119:                    for (int i = 0; i < pvalues.length; i++) {
120:                        if (i > 0)
121:                            result.append(", ");
122:                        result.append(pvalues[i]);
123:                    }
124:                    log.info("         parameter=" + result.toString());
125:                }
126:                log.info("          pathInfo=" + request.getPathInfo());
127:                log.info("          protocol=" + request.getProtocol());
128:                log.info("       queryString=" + request.getQueryString());
129:                log.info("        remoteAddr=" + request.getRemoteAddr());
130:                log.info("        remoteHost=" + request.getRemoteHost());
131:                log.info("        remoteUser=" + request.getRemoteUser());
132:                log.info("requestedSessionId="
133:                        + request.getRequestedSessionId());
134:                log.info("            scheme=" + request.getScheme());
135:                log.info("        serverName=" + request.getServerName());
136:                log.info("        serverPort=" + request.getServerPort());
137:                log.info("       servletPath=" + request.getServletPath());
138:                log.info("          isSecure=" + request.isSecure());
139:                log
140:                        .info("---------------------------------------------------------------");
141:
142:                // Perform the request
143:                getNext().invoke(request, response);
144:
145:                // Log post-service information
146:                log
147:                        .info("---------------------------------------------------------------");
148:                log.info("          authType=" + request.getAuthType());
149:                log.info("     contentLength=" + response.getContentLength());
150:                log.info("       contentType=" + response.getContentType());
151:                Cookie rcookies[] = response.getCookies();
152:                for (int i = 0; i < rcookies.length; i++) {
153:                    log.info("            cookie=" + rcookies[i].getName()
154:                            + "=" + rcookies[i].getValue() + "; domain="
155:                            + rcookies[i].getDomain() + "; path="
156:                            + rcookies[i].getPath());
157:                }
158:                String rhnames[] = response.getHeaderNames();
159:                for (int i = 0; i < rhnames.length; i++) {
160:                    String rhvalues[] = response.getHeaderValues(rhnames[i]);
161:                    for (int j = 0; j < rhvalues.length; j++)
162:                        log.info("            header=" + rhnames[i] + "="
163:                                + rhvalues[j]);
164:                }
165:                log.info("           message=" + response.getMessage());
166:                log.info("        remoteUser=" + request.getRemoteUser());
167:                log.info("            status=" + response.getStatus());
168:                log
169:                        .info("===============================================================");
170:
171:            }
172:
173:            /**
174:             * Return a String rendering of this object.
175:             */
176:            public String toString() {
177:
178:                StringBuffer sb = new StringBuffer("RequestDumperValve[");
179:                if (container != null)
180:                    sb.append(container.getName());
181:                sb.append("]");
182:                return (sb.toString());
183:
184:            }
185:
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.