JSP: HTTP Helper - A JSP for Test Program
This JSP is something you can use to test forms and HTML pages that pass data to a JSP or Servlet. Just link the form you wish to test to httpHelper.jsp
, and the JSP will show you what's been sent to it.
Get Source for: httpHelper.jsp
1:<html> 2:<head> 3:<title>JSP HTTP Header Tool</title> 4:</head> 5:<body> 6:<h2>JSP HTTP Header Tool</h2> 7:<h3>HTTP Request</h3> 8:<%-- First, get the first line of the HTTP request --%> 9:<p><%= request.getMethod() %> <%= request.getRequestURI() %> <%= request.getProtocol() %></p> 10:<h3>Form Parameters Passed and their values</h3> 11:<p> 12:<%-- Get the names of the parameters passed form the form. Then walk through the list --%> 13:<% java.util.Enumeration e2 = request.getParameterNames(); %> 14:<% while (e2.hasMoreElements()){ %> 15: <% String name = (String) e2.nextElement(); %> 16: <b>Param: </b><%= name %> <b>Param Value: </b><%= request.getParameter(name) %><br> 17: <% } %> 18: 19:</p> 20:<p> 21:<h3>Web Server Info</h3> 22:<%-- Each of these informational values can be obtained from the Request object --%> 23:<b>Web Server Name:</b> <%= request.getServerName() %> <br> 24:<b>Web Server Port:</b> <%= request.getServerPort() %> <br> 25:<b>Browser address:</b> <%= request.getRemoteAddr() %> <br> 26:<b>Browser Host Name:</b> <%= request.getRemoteHost() %><br> 27:<b>Request URI:</b> <%= request.getRequestURI() %><br> 28:<b>Query Sting:</b> <%= request.getQueryString() %><br> 29:<b>Path Info: </b> <%= request.getPathInfo() %><br> 30:<b>Path Translated:</b> <%= request.getPathTranslated() %><br> 31:</p> 32:<h3>HTTP Header (Not in order)</h3> 33:<%-- Like we did with the form values, get the header names pass in, and walk through the list --%> 34:<% java.util.Enumeration e = request.getHeaderNames(); %> 35:<p> 36:<% while (e.hasMoreElements()){ %> 37: <% String name = (String) e.nextElement(); %> 38: <b><%= name %>:</b> <%= request.getHeader(name) %><br> 39: <% } %> 40:</p> 41:</body> 42:</html>