1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import java.io.*;
21 import java.text.*;
22 import java.util.*;
23 import javax.servlet.*;
24 import javax.servlet.http.*;
25
26 import util.HTMLFilter;
27
28 /**
29 * Example servlet showing request information.
30 *
31 * @author James Duncan Davidson <duncan@eng.sun.com>
32 */
33
34 public 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
56
57
58
59
60
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