• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HTTP Protocol & Servlets

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How could I get all the information (example below) sent by a client using servlets?

Example:
GET /index.html HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-powerpoint, application/vnd.ms-excel, 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
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use request methods request.getHeaderNames() and request.getHeader(headerName).
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

request.getHeader("String")

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.

getHeaderNames():
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:

request.getHeaderNames();

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.

Regards,
Pk
 
Gerardo Tagliani
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks people!

I will try!
 
reply
    Bookmark Topic Watch Topic
  • New Topic