Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Servlets and the fly likes HTTP Protocol & Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "HTTP Protocol & Servlets" Watch "HTTP Protocol & Servlets" New topic

HTTP Protocol & Servlets

Gerardo Tagliani

Joined: May 14, 2002
Posts: 2
How could I get all the information (example below) sent by a client using servlets?

GET /index.html HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/, application/, application/msword, */*
Accept-Language: pt-br
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Host: localhost
Connection: Keep-Alive
Carol Enderlin
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
You can use request methods request.getHeaderNames() and request.getHeader(headerName).
Periakaruppan Thiagarajan
Ranch Hand

Joined: Jul 26, 2005
Posts: 65
getHeader(String name):
The method getHeader(String name) of request object is used to return the value of header given in request. The returned value of header is a string.

General Syntax:


In the above the returned value is a String.

For instance

String exfosys = request.getHeader("exforsys")

The above would retrieve the value of the HTTP header whose name is exforsys in JSP.

The method getHeaderNames() of request object returns all the header names in the request. This method is therefore used to find the available headers. The value returned is as a enumerator of all header names.

General Syntax:


In the above the returned value is an enumerator.

For example

Enumeration exforsys = request.getHeaderNames();

The above returns all header names under the enumerator exforsys.

Gerardo Tagliani

Joined: May 14, 2002
Posts: 2
Thanks people!

I will try!
I agree. Here's the link:
subject: HTTP Protocol & Servlets
It's not a secret anymore!