Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

servlet getHeaders

Hi,

I was reading as below

getHeaders
'
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. If a header name is
repeated in the request, version 2.1 servlets cannot access the
later values without reading the raw input stream, as
getHeader returns the value of the first occurrence of the
header only. In version 2.2, however, getHeaders returns an
Enumeration of the values of all occurrences of the header.
Finally, in addition to looking up the request headers, you can get information
on the main request line itself, also by means of methods in Http-
ServletRequest.'




Accept-Encoding

This header designates the types of encodings that the client knows how to handle. If it receives this header, the server is free to encode the page by using the format specified (usually to reduce transmission time), sending the Content-Encoding response header to indicate that it has
done so. This encoding type is completely distinct from the MIME type of the actual document (as specified in the Content-Type response header), since this encoding is reversed before the browser decides what to do with the content. On the other hand, using an encoding the browser doesn’t understand results in totally incomprehensible pages. Consequently, it is critical that you explicitly check the Accept-Encoding header before using any type of content encoding. Values of gzip or compress are the two standard possibilities.



Cookie

This header is used to return cookies to servers that previously sent them to the browser.This rarely used header lets the client tell the server what kinds of behaviors it expects. The one standard value for this header, 100-continue, is sent by a browser that will be sending an attached document and wants to know if the server will accept it. The server should send a status code of either 100 (Continue) or 417 (Expectation Failed) in such a case.



When i ran sameple program with below code

out.print("<br><br>User agent Header value is :- "
        + request.getHeader("user-agent"));



It outputted mozilla eventhough the servlet ran in eclipse window it self. I wonder why it showed mozilla. Please advise

I have not understood clearly what they means.

Please advise.

Any links resources ideas highly appreciated. Thanks in advance
userAgent.jpg
ASKER CERTIFIED SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

>>>In version 2.2, however, getHeaders returns an
Enumeration of the values of all occurrences of the header.
Finally, in addition to looking up the request headers, you can get information
on the main request line itself, also by means of methods in Http-
ServletRequest.'



how version 2.2 is different from previous version of servlet. ??




>>The one standard value for this header, 100-continue, is sent by a browser that will be sending an attached document and wants to know if the server will accept it. The server should send a status code of either 100 (Continue) or 417 (Expectation Failed) in such a case.

what is 100 and 417. I have not understood this. Is cookie is part of header too??

Please advise
It's using the default system web browser, which is the mozilla engine. If you want to change it you can do it from the General->Web Browser option.

Guys sorry for this comment, I am not sure how it got here. I probably wanted to answer another question and posted here accidentally!