source: nutchez-0.1/tomcat/webapps/examples/WEB-INF/classes/RequestInfoExample.java @ 79

Last change on this file since 79 was 66, checked in by waue, 15 years ago

NutchEz - an easy way to nutch

File size: 3.9 KB
RevLine 
[66]1/*
2* Licensed to the Apache Software Foundation (ASF) under one or more
3* contributor license agreements.  See the NOTICE file distributed with
4* this work for additional information regarding copyright ownership.
5* The ASF licenses this file to You under the Apache License, Version 2.0
6* (the "License"); you may not use this file except in compliance with
7* the License.  You may obtain a copy of the License at
8*
9*     http://www.apache.org/licenses/LICENSE-2.0
10*
11* Unless required by applicable law or agreed to in writing, software
12* distributed under the License is distributed on an "AS IS" BASIS,
13* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14* See the License for the specific language governing permissions and
15* limitations under the License.
16*/
17/* $Id: RequestInfoExample.java 500674 2007-01-27 23:15:00Z markt $
18 *
19 */
20
21import java.io.*;
22import java.util.*;
23import javax.servlet.*;
24import javax.servlet.http.*;
25
26import util.HTMLFilter;
27
28/**
29 * Example servlet showing request information.
30 *
31 * @author James Duncan Davidson <duncan@eng.sun.com>
32 */
33
34public class RequestInfoExample extends HttpServlet {
35
36
37    ResourceBundle rb = ResourceBundle.getBundle("LocalStrings");
38
39    public void doGet(HttpServletRequest request,
40                      HttpServletResponse response)
41        throws IOException, ServletException
42    {
43        response.setContentType("text/html");
44
45        PrintWriter out = response.getWriter();
46        out.println("<html>");
47        out.println("<body>");
48        out.println("<head>");
49
50        String title = rb.getString("requestinfo.title");
51        out.println("<title>" + title + "</title>");
52        out.println("</head>");
53        out.println("<body bgcolor=\"white\">");
54
55        // img stuff not req'd for source code html showing
56  // all links relative!
57
58        // XXX
59        // making these absolute till we work out the
60        // addition of a PathInfo issue
61 
62        out.println("<a href=\"../reqinfo.html\">");
63        out.println("<img src=\"../images/code.gif\" height=24 " +
64                    "width=24 align=right border=0 alt=\"view code\"></a>");
65        out.println("<a href=\"../index.html\">");
66        out.println("<img src=\"../images/return.gif\" height=24 " +
67                    "width=24 align=right border=0 alt=\"return\"></a>");
68
69        out.println("<h3>" + title + "</h3>");
70        out.println("<table border=0><tr><td>");
71        out.println(rb.getString("requestinfo.label.method"));
72        out.println("</td><td>");
73        out.println(request.getMethod());
74        out.println("</td></tr><tr><td>");
75        out.println(rb.getString("requestinfo.label.requesturi"));
76        out.println("</td><td>");       
77        out.println(HTMLFilter.filter(request.getRequestURI()));
78        out.println("</td></tr><tr><td>");       
79        out.println(rb.getString("requestinfo.label.protocol"));
80        out.println("</td><td>");       
81        out.println(request.getProtocol());
82        out.println("</td></tr><tr><td>");
83        out.println(rb.getString("requestinfo.label.pathinfo"));
84        out.println("</td><td>");       
85        out.println(HTMLFilter.filter(request.getPathInfo()));
86        out.println("</td></tr><tr><td>");
87        out.println(rb.getString("requestinfo.label.remoteaddr"));
88
89  String cipherSuite=
90      (String)request.getAttribute("javax.servlet.request.cipher_suite");
91        out.println("</td><td>");               
92        out.println(request.getRemoteAddr());
93        out.println("</table>");
94
95  if(cipherSuite!=null){
96      out.println("</td></tr><tr><td>"); 
97      out.println("SSLCipherSuite:");
98      out.println("</td>");
99      out.println("<td>");     
100      out.println(request.getAttribute("javax.servlet.request.cipher_suite"));
101      out.println("</td>");     
102  }
103 
104    }
105
106    public void doPost(HttpServletRequest request,
107                      HttpServletResponse response)
108        throws IOException, ServletException
109    {
110        doGet(request, response);
111    }
112
113}
114
Note: See TracBrowser for help on using the repository browser.