1 16 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 33 34 public class RequestHeaderExample extends HttpServlet { 35 36 ResourceBundle rb = ResourceBundle.getBundle("LocalStrings"); 37 38 public void doGet(HttpServletRequest request, 39 HttpServletResponse response) 40 throws IOException, ServletException 41 { 42 response.setContentType("text/html"); 43 44 PrintWriter out = response.getWriter(); 45 out.println("<html>"); 46 out.println("<body bgcolor=\"white\">"); 47 out.println("<head>"); 48 49 String title = rb.getString("requestheader.title"); 50 out.println("<title>" + title + "</title>"); 51 out.println("</head>"); 52 out.println("<body>"); 53 54 56 60 out.println("<a HREF=\"../reqheaders.html\">"); 61 out.println("<img SRC=\"../images/code.gif\" height=24 " + 62 "width=24 align=right border=0 alt=\"view code\"></a>"); 63 out.println("<a HREF=\"../index.html\">"); 64 out.println("<img SRC=\"../images/return.gif\" height=24 " + 65 "width=24 align=right border=0 alt=\"return\"></a>"); 66 67 out.println("<h3>" + title + "</h3>"); 68 out.println("<table border=0>"); 69 Enumeration e = request.getHeaderNames(); 70 while (e.hasMoreElements()) { 71 String headerName = (String )e.nextElement(); 72 String headerValue = request.getHeader(headerName); 73 out.println("<tr><td bgcolor=\"#CCCCCC\">"); 74 out.println(HTMLFilter.filter(headerName)); 75 out.println("</td><td>"); 76 out.println(HTMLFilter.filter(headerValue)); 77 out.println("</td></tr>"); 78 } 79 out.println("</table>"); 80 } 81 82 public void doPost(HttpServletRequest request, 83 HttpServletResponse response) 84 throws IOException, ServletException 85 { 86 doGet(request, response); 87 } 88 89 } 90 91 | Popular Tags |