1
+ /*
2
+ * Copyright 2016 Google Inc. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
1
17
package com .google .appengine .demos ;
2
18
3
19
import java .io .IOException ;
13
29
public class DumpServlet extends HttpServlet {
14
30
15
31
@ Override
16
- protected void doGet (HttpServletRequest request ,
17
- HttpServletResponse response ) throws ServletException ,
18
- IOException {
32
+ protected void doGet (HttpServletRequest request , HttpServletResponse response )
33
+ throws ServletException , IOException {
19
34
response .setContentType ("text/html" );
20
35
response .setStatus (HttpServletResponse .SC_OK );
21
36
@@ -28,19 +43,42 @@ protected void doGet(HttpServletRequest request,
28
43
out .printf ("getServletContextName=%s%n" , getServletContext ().getServletContextName ());
29
44
out .printf ("virtualServerName=%s%n" , getServletContext ().getVirtualServerName ());
30
45
out .printf ("contextPath=%s%n" , getServletContext ().getContextPath ());
31
- out .printf ("version=%d.%d%n" , getServletContext ().getMajorVersion (), getServletContext ().getMinorVersion ());
32
- out .printf ("effectiveVersion=%d.%d%n" , getServletContext ().getEffectiveMajorVersion (), getServletContext ().getEffectiveMinorVersion ());
46
+ out .printf (
47
+ "version=%d.%d%n" ,
48
+ getServletContext ().getMajorVersion (),
49
+ getServletContext ().getMinorVersion ());
50
+ out .printf (
51
+ "effectiveVersion=%d.%d%n" ,
52
+ getServletContext ().getEffectiveMajorVersion (),
53
+ getServletContext ().getEffectiveMinorVersion ());
33
54
out .println ("</pre>" );
34
55
out .println ("<h2>Request Fields:</h2>" );
35
56
out .println ("<pre>" );
36
- out .printf ("remoteHost/Addr:port=%s/%s:%d%n" , request .getRemoteHost (), request .getRemoteAddr (), request .getRemotePort ());
37
- out .printf ("localName/Addr:port=%s/%s:%d%n" , request .getLocalName (), request .getLocalAddr (), request .getLocalPort ());
38
- out .printf ("scheme=%s method=%s protocol=%s%n" , request .getScheme (), request .getMethod (), request .getProtocol ());
57
+ out .printf (
58
+ "remoteHost/Addr:port=%s/%s:%d%n" ,
59
+ request .getRemoteHost (),
60
+ request .getRemoteAddr (),
61
+ request .getRemotePort ());
62
+ out .printf (
63
+ "localName/Addr:port=%s/%s:%d%n" ,
64
+ request .getLocalName (),
65
+ request .getLocalAddr (),
66
+ request .getLocalPort ());
67
+ out .printf (
68
+ "scheme=%s method=%s protocol=%s%n" ,
69
+ request .getScheme (),
70
+ request .getMethod (),
71
+ request .getProtocol ());
39
72
out .printf ("serverName:serverPort=%s:%d%n" , request .getServerName (), request .getServerPort ());
40
73
out .printf ("requestURI=%s%n" , request .getRequestURI ());
41
74
out .printf ("requestURL=%s%n" , request .getRequestURL ().toString ());
42
- out .printf ("contextPath|servletPath|pathInfo=%s|%s|%s%n" , request .getContextPath (), request .getServletPath (), request .getPathInfo ());
43
- out .printf ("session/new=%s/%b%n" , request .getSession (true ).getId (), request .getSession ().isNew ());
75
+ out .printf (
76
+ "contextPath|servletPath|pathInfo=%s|%s|%s%n" ,
77
+ request .getContextPath (),
78
+ request .getServletPath (),
79
+ request .getPathInfo ());
80
+ out .printf (
81
+ "session/new=%s/%b%n" , request .getSession (true ).getId (), request .getSession ().isNew ());
44
82
out .println ("</pre>" );
45
83
out .println ("<h2>Request Headers:</h2>" );
46
84
out .println ("<pre>" );
0 commit comments