getHeader() Method Of The Request Object

This section gives you the best illustration about the getHeader() method of the request object.

getHeader() Method Of The Request Object

getHeader() Method Of The Request Object

     

This section gives you the best illustration about the getHeader() method of the request object. Here, you will learn more about the getHeader() method like why is it used and how is it implemented. Through the help of the section you will get the complete information about the HTTP header.

This method returns the value of the HTTP header like query string or the URL. This method takes a string parameter which is the header name retrieved by the method getHeaderNames() of the request object that gives all the HTTP header names in the enumeration form which has to be converted into string form later for getting the value of the value of the HTTP header from if one by one.

Here is the code of the GetHeaderMethod.jsp file:

<%@page import="java.util.*" %>
<%
	String headername = "";
	for(Enumeration e = request.getHeaderNames();
 e.hasMoreElements();){
		headername = (String)e.nextElement();
		out.println(request.getHeader
(headername) + "<br/>");
	}
%>

Output for the above mentioned file:

Download GetHeaderMethod.jsp file.