Home Jsp Simple-jsp-example Request Headers In EL



Request Headers In EL
Posted on: February 11, 2008 at 12:00 AM
Whenever an http client sends a request, it also sends the headers with it.

Request Headers In EL

        

Whenever an http client sends a request, it also sends the headers with it. All the headers are optional except Content-length, which is required only for POST requests. Here is the list of most commonly used headers are:

1) Accept : The MIME types the browser prefers.

2) Accept- Encoding: The types of data encodings the browser knows how to decode.

3) Accept- Charset: The character set the browser expects.

4) Content-Length: It is mostly used for POST messages, it tells how much data is attached.

5) Cookie: It is one of the most frequently used headers, it returns the cookies.

6) Accept- Language: The language the browser is expecting.

Not all the headers are specified here.

In EL we can retrieve the headers, but not as we do in scripting. To access the request headers we need a simple trick, by using that trick we will be able to access the Request Parameters.

The code of the program is given below:

 

<html>
	<head>
		<title>To retrieve a specific header</title>
	</head>
	<body>
		<h1>By using  the EL we can retrieve the request headers</h1>
		<b>The Host is  :  ${header["host"]}</b><br>
		<b>The method is : ${pageContext.request.method}</b><br>
		<b>The request URI is : ${pageContext.request.requestURI}</b><br>
		<b>The requested protocol is : ${pageContext.request.protocol}</b>
	</body>
</html>

The output of the program is given below:

Download this example.

Related Tags for Request Headers In EL:
ccombrowserlistencodingdatauipostiotypesheadersedtyperequestheadersmimecontentcodinglengthrowdecodeforrowstowserequireoptionposrefwseliusepeimcebrowseinnomheadntososoptionaladesrequestsstscommonallmehowacceptreferwhichscontent-lengthatquestkisirimellpreeaexceptarcodcodeccssthstfeprmostmionlyodeonomonl


More Tutorials from this section

Ask Questions?    Discuss: Request Headers In EL  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.