Getting HTTP Request Headers in a JSP

By: Bruce W. Perry Emailed: 1672 times Printed: 2149 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

The JSTL v1.0 makes all existing request headers available via the header implicit object. The JSTL automatically makes this variable available to JSPs; the header object evaluates to a java.util.Map type.

In sample program below, the c:forEach tag iterates over this Map and stores each header name and value in the loop variable named by c:forEach's var attribute. The c:forEach var attribute is implemented as a java.util.Map.Entry type, which is a data type that stores keys and their values. The c:out tag displays each header name by using EL format: ${req.key}. Consequently c:out displays the value with ${req.value}.

Viewing the request header names and values in a JSP
<%@ taglib uri="" prefix="c" %>

<head><title>Request Headers</title></head>
<h2>Here are the Request Header names and values</h2>

<c:forEach var="req" items="${header}">

    <strong><c:out value=
        "${req.key}"/></strong>: <c:out value="${req.value}"/><br>



JSP Home | All JSP Tutorials | Latest JSP Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.

Bookmark and Share


Be the first one to add a comment

Your name (required):

Your email(required, will not be shown to the public):

Your sites URL (optional):

Your comments:

More Tutorials by Bruce W. Perry
Embedding MP3 audio file in a JSP
Embedding a QuickTime movie in a JSP
Getting HTTP Request Headers in a JSP
Using a DataSource from WebLogic in a JSP
Creating a JavaBean to Connect with Google API
Deploying an Individual JSP on Tomcat
Writing your first JSP page

More Tutorials in JSP
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: ` Permission denied <null>:80
JSP Alert Example
JSP CheckBox Example
Uploading an Image to a Database using JSP
Uploading a file to a server using JSP
A JSP page that gets properties from a bean
The page Directive in JSP
The taglib, tag, include, attribute and the variable Directive in JSP
Declarations in JSP
Scriptlets and Expressions in JSP
Tag Libraries in JSP
The Request Object in JSP
The Response Object in JSP
The Out Object in JSP
The Session Object in JSP

More Latest News
Most Viewed Articles (in JSP )
JSP Example to connect to MS SQL database and retrieve records
Comparison operators in JSP
JSP Program for display Date
JSP CheckBox Example
JSP Alert Example
Server-side plug-Ins Connection refused: connect
Encrypting Passwords in Tomcat using Servlets
What are the different scopes in JSP?
Automatically Refreshing a JSP
Uploading an Image to a Database using JSP
Form processing in JSP
Handling Events
Password Object
Math Object
Most Emailed Articles (in JSP)
Textarea Object
Click to Activate and Use this control
Embedding java codes in jsp sciptlets
Debugging Servlets
The Servlet Life Cycle
The JSP Program running first Time.
Document Object Connection refused: connect
The Basic Syntax Expression Language in JSP
Automatically Refreshing a JSP
IIS and Tomcat - how to configure to work together
What is JSP?
Server Side Programming
Tags using in jsp
Form processing in JSP