File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Http request and response headers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Http request and response headers" Watch "Http request and response headers" New topic

Http request and response headers

devayani Devasthali
Ranch Hand

Joined: Aug 25, 2005
Posts: 40
I have tried request.getHeader() method along with getHeaderNames().
with HeaderNames() got many results as - accept, referer etc.
still didnt get the exact meaning and use of them
where shall I get the exact info abt the same?
can u pls help me in foinding it out?
thanx in advance
Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
Generally header information is for the browsers to intimate the required behavior of the page being displayed.
Example if you don�t wish to cache the page, you can set this in the header of the page like this.

response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 1);

Which is equlivent of adding this html tags in the static html page.

<meta HTTP-EQUIV="Pragma" content="no-cache">
<meta HTTP-EQUIV="Expires" content="-1">

Like this there are many more header information that can be set. Details can be found in some good HTML books or even Goggle can help you�.


Sharing is learning
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
For a comprehensive treatment, read RFC 2616 - HTTP/1.1:

headers in general

request headers

response headers
[ February 16, 2006: Message edited by: Ulf Dittmer ]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

"devayani Dev", you have already been asked on at least one previous occasion to adjust your display name to meet JavaRanch standards. This is not optional. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it prior to your next post.

Be aware that accounts with invalid display names are removed.

JavaRanch Sheriff

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Http request and response headers
It's not a secret anymore!