New Technologies

  • Java
  • Javascript
  • DTML
  • Dot Net
  • ASP .Net
  • C# .Net
  • PHP
Your Ad Here
Showing posts with label request.getheader. Show all posts
Showing posts with label request.getheader. Show all posts

Saturday, March 8, 2008

Code to Get All the Headers in Java

Enumeration enum1 = request.getHeaderNames();

String name = "user-agent";

String value = request.getHeader(name);

if (value == null) {

// The request header was not present

}

for (; enum1.hasMoreElements(); ) {

// Get the name of the request header

name = (String)enum1.nextElement();

out.println(name);


// Get a value of the request header

value = request.getHeader(name);


// If the request header can appear more than once, get all values

Enumeration valuesEnum = request.getHeaders(name);

for (; valuesEnum.hasMoreElements(); ) {

// Get a value of the request header

value = (String)valuesEnum.nextElement();


out.println(value+"
");

}

}
Your Ad Here