Reading headers is straightforward; just call the get Header method of HttpServletRequest with the name of the header.
Header names are not case sensitive. So,
For example, request.getHeader ("Connection") is interchangeable with
request.getHeader ("connection").
request.getHeader ("connection").
Always check that the result of request.getHeader is non-null before using it.
A few headers are so commonly used that they have special access methods in HttpServletRequest. Following is a summary.
· get Cookies:-
- The get Cookies method returns the contents of the Cookie header, parsed and stored in an array of Cookie objects.
· getAuthType and getRemoteUser:-
- The getAuthType and getRemoteUser methods break the Authorization header into its component pieces.
· getContentLength:-
- The getContentLength method returns the value of the Content-Length header (as an int).
· getContentType:-
- The getContentType method returns the value of the Content-Type header (as a String).
· getDateHeader and getIntHeader:-
- The getDateHeader and getIntHeader methods read the specified headers and then convert them to Date and int values, respectively.
· getHeaderNames:-
- Rather than looking up one particular header, you can use the getHeaderNames method to get an Enumeration of all header names received on this particular request.
· getHeaders:-
- In most cases, each header name appears only once in the request. Occasionally, however, a header can appear multiple times, with each occurrence listing a separate value. Accept-Language is one such example. You can use getHeaders to obtain an Enumeration of the values of all occurrences of the header.
· getMethod:-
- The get Method method returns the main request method (normally, GET or POST, but methods like HEAD, PUT, and DELETE are possible).
· getRequestURI:-
- The getRequestURI method returns the part of the URL that comes after the host and port but before the form data.
· getQueryString:-
- The getQueryString method returns the form data.
· getProtocol:-
- The getProtocol method returns the third part of the request line

About
Tags
Popular

