Popular Posts

Monday, June 1, 2009

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>

</tr>

<tr>

<td width="33%"><b><font color="#800000">Path translated:</font></b></td>

<td width="67%"><font color="#FF0000"><%=request.getPathTranslated()%></font></td>

</tr>

<tr>

<td width="33%"><b><font color="#800000">Query String:</font></b></td>

<td width="67%"><font color="#FF0000"><%=request.getQueryString()%></font></td>

</tr>

<tr>

<td width="33%"><b><font color="#800000">Content length:</font></b></td>

<td width="67%"><font color="#FF0000"><%=request.getContentLength()%></font></td>

</tr>

<tr>

<td width="33%"><b><font color="#800000">Content type:</font></b></td>

<td width="67%"><font color="#FF0000"><%=request.getContentType()%></font></td>

</tr>

<tr>

<td width="33%"><b><font color="#800000">Server name:</font></b></td>

<td width="67%"><font color="#FF0000"><%=request.getServerName()%></font></td>

</tr>

<tr>

<td width="33%"><b><font color="#800000">Server port:</font></b></td>

<td width="67%"><font color="#FF0000"><%=request.getServerPort()%></font></td>

</tr>

<tr>

<td width="33%"><b><font color="#800000">Remote user:</font></b></td>

<td width="67%"><font color="#FF0000"><%=request.getRemoteUser()%></font></td>

</tr>

<tr>

<td width="33%"><b><font color="#800000">Remote address:</font></b></td>

<td width="67%"><font color="#FF0000"><%=request.getRemoteAddr()%></font></td>

</tr>

<tr>

<td width="33%"><b><font color="#800000">Remote host:</font></b></td>

<td width="67%"><font color="#FF0000"><%=request.getRemoteHost()%></font></td>

</tr>

<tr>

<td width="33%"><b><font color="#800000">Authorization scheme:</font></b></td>

<td width="67%"><font color="#FF0000"><%=request.getAuthType()%></font></td>

</tr>

</table>

</div>

</body>

</html>

2 comments:

  1. This is the precise weblog for anybody who needs to seek out out about this topic. You notice so much its almost arduous to argue with you. You positively put a brand new spin on a subject that's been written about for years. Nice stuff, simply nice!

    ReplyDelete
  2. Very great post. I simply stumbled upon your blog and wanted to say that I have really enjoyed browsing your weblog posts. After all I’ll be subscribing on your feed and I am hoping you write again very soon!

    ReplyDelete