[ Team LiB ] |
Common Request HeadersThe headers you saw in Figures 4.4 and 4.5 represent the most common set of request headers you'll receive. Netscape browsers might also send an Accept-Charset request header. This section explains those headers in a little more detail. The Accept HeaderThe Accept header indicates the kind of content the browser can accept. The order of the items is typically the order the browser prefers. In other words, when the browser lists text/xml before text/html it says that it prefers XML documents to HTML documents. Usually, you'll see */* at the end of the list, meaning that the browser accepts anything, but it prefers those it has already listed. Values and Options Vary Between Browsers
If you look at the Accept header sent by a wireless phone, you'll see that it lists HTML text and bitmap images after the */*, indicating that it prefers just about anything to HTML or bitmaps! Here is the Accept header sent from a wireless phone:
The Accept-Language HeaderThe Accept-Language header gives you a hint as to what language the browser prefers (actually, the browser's user, because the browser doesn't speak human languages). For English, you might see just en or you might see en-us or en-uk specifying English for a particular locale such as the United States or the United Kingdom. You can use this header to provide language-specific content automatically. You'll learn more about this idea in Hour 22, "Internationalization." The Accept-Charset HeaderIf present, the Accept-Charset header indicates the preferred character set(s) that the browser accepts. For Netscape running in an English-speaking locale, you'll most likely see this kind of header:
The User-Agent HeaderOf all the headers sent by the browser, the User-Agent header is probably the most useful because it indicates what kind of browser is making the request. Oddly, both Netscape and Internet Explorer identify themselves as Mozilla, which was the nickname for the early Netscape browser. (There is now a browser called Mozilla, which was born from the code for Netscape 5.) Mozilla�A Monster Browser
When Internet Explorer (IE) first came out, it lagged behind Netscape in usage, and gradually added features to become a reasonable alternative by the time IE version 3 came along. By identifying itself as Mozilla-compatible, IE is telling the Web server that it can handle anything Mozilla can. If you want to figure out whether the browser is Netscape or IE, only IE sends the MSIE string as part of its User-Agent header. Thus, you can do the following test in your JSP or servlet:
You can perform similar tests to detect other browsers, such as Opera. In Case of Trouble
|
[ Team LiB ] |
No comments:
Post a Comment