Get page header information using jsp

by Vinoth 2009-07-18 19:08:49


< %@ page import="java.util.Enumeration" % >
< h2 > Page Header Information < /h2 >
< table border=1 >
<%
Enumeration eNames = request.getHeaderNames();
while (eNames.hasMoreElements()) {
String name = (String) eNames.nextElement();
String value = normalize(request.getHeader(name));
//String value = request.getHeader(name);
%>
< tr > < td > < %=name% > < /td > < td > <%=value% > </ td > < /tr > <%}% >
< /table >
<%!
private String normalize(String value)
{
StringBuffer sb = new StringBuffer();
for (int i = 0; i < value.length(); i++) {
char c = value.charAt(i);
sb.append(c);
if (c == ';')
sb.append("
");
}
return sb.toString();
}
%>


HTTP Request Headers Received













hostlocalhost:8181
user-agentMozilla/5.0 (Windows;
U;
Windows NT 5.1;
en-US;
rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1
accepttext/html,application/xhtml+xml,application/xml;
q=0.9,*/*;
q=0.8
accept-languageen-us,en;
q=0.5
accept-encodinggzip,deflate
accept-charsetISO-8859-1,utf-8;
q=0.7,*;
q=0.7
keep-alive300
connectionkeep-alive
cookieJSESSIONID=992EA52BA3CC3723D5DC07C0FCB87A1A
cache-controlmax-age=0

Tagged in:

1896
like
0
dislike
0
mail
flag

You must LOGIN to add comments