getHeaderNames() Method Of The Request Object

In this section, you will learn how to get the header name of the host server.

getHeaderNames() Method Of The Request Object

getHeaderNames() Method Of The Request Object

     

In this section, you will learn how to get the header name of the host server. This section gives you the brief introduction about the getHeaderNames() method of the request object that is used for getting the name of all the header names existed in the current session environment of the page. This method returns all the header names in the enumeration form that are retrieved one by one by enumerating the data.

There is a example with the complete JSP code is provided by the section i.e. very helpful in developing your JSP application. You can directly copy from the page and paste it into your application.

Here is the JSP code of GetHeaderNamesMethod.jsp file:

<%@page import="java.util.*" %>
<table align="center" border="1" cellpadding="0" cellspacing="0" bgcolor="red">
<%
	String headername = "";
	for(Enumeration e = request.getHeaderNames(); e.hasMoreElements();){
		headername = (String)e.nextElement();
%>
	<tr>
		<td><b><%= headername %></b></td>
	</tr>
<%}%>

Output for the above JSP file:

Download JSP file.