Reading Request Information
When an HTTP client such as web browser sends a request to a wen server, along with the request it also sends some HTTP variables like Remote address, Remote host, Content type etc. In some cases these variables are useful to the programmers. So here is the code of the jsp file which prints the HTTP request information:
<%@page contentType="text/html" import="java.util.*" %> <!-- http://www.roseindia.net/jsp --> <html> <body> <p><font size="5" color="#800000">Request Information:</font></p> <div align="left"> <table border="0" cellpadding="0" cellspacing="0" width="70%" bgcolor="#EEFFCA"> <tr> <td width="33%"><b><font color="#800000">Request Method:</font></b></td> <td width="67%"><font color="#FF0000"><%=request.getMethod()%></font></td> </tr> <tr> <td width="33%"><b><font color="#800000">Request URI:</font></b></td> <td width="67%"><font color="#FF0000"><%=request.getRequestURI()%></font></td> </tr> <tr> <td width="33%"><b><font color="#800000">Request Protocol:</font></b></td> <td width="67%"><font color="#FF0000"><%=request.getProtocol()%></font></td> </tr> <tr> <td width="33%"><b><font color="#800000">Path Info:</font></b></td> <td width="67%"><font color="#FF0000"><%=request.getPathInfo()%></font></td> 0 </tr> <tr> <td width="33%"><b><font color="#800000">Path translated:</font></b></td> 1 <td width="67%"><font color="#FF0000"><%=request.getPathTranslated()%></font></td> </tr> <tr> 2 <td width="33%"><b><font color="#800000">Query String:</font></b></td> <td width="67%"><font color="#FF0000"><%=request.getQueryString()%></font></td> </tr> 3 <tr> <td width="33%"><b><font color="#800000">Content length:</font></b></td> <td width="67%"><font color="#FF0000"><%=request.getContentLength()%></font></td> 4 </tr> <tr> <td width="33%"><b><font color="#800000">Content type:</font></b></td> 5 <td width="67%"><font color="#FF0000"><%=request.getContentType()%></font></td> </tr> <tr> 6 <td width="33%"><b><font color="#800000">Server name:</font></b></td> <td width="67%"><font color="#FF0000"><%=request.getServerName()%></font></td> </tr> 7 <tr> <td width="33%"><b><font color="#800000">Server port:</font></b></td> <td width="67%"><font color="#FF0000"><%=request.getServerPort()%></font></td> 8 </tr> <tr> <td width="33%"><b><font color="#800000">Remote user:</font></b></td> 9 <td width="67%"><font color="#FF0000"><%=request.getRemoteUser()%></font></td> </tr> <tr> 0 <td width="33%"><b><font color="#800000">Remote address:</font></b></td> <td width="67%"><font color="#FF0000"><%=request.getRemoteAddr()%></font></td> </tr> 1 <tr> <td width="33%"><b><font color="#800000">Remote host:</font></b></td> <td width="67%"><font color="#FF0000"><%=request.getRemoteHost()%></font></td> 2 </tr> <tr> <td width="33%"><b><font color="#800000">Authorization scheme:</font></b></td> 3 <td width="67%"><font color="#FF0000"><%=request.getAuthType()%></font></td> </tr> </table> 4 </div> </body> </html> |