• Post Reply Bookmark Topic Watch Topic
  • New Topic

help understand the following servlet code  RSS feed

 
trupti nigam
Ranch Hand
Posts: 640
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
The following examples is from the weblogic/examples directory.
I am not able to follow the below code snippet ..especially the user-agent?/
public void service(HttpServletRequest req, HttpServletResponse res)
throws IOException
{

String userAgent = req.getHeader("User-agent");
boolean isHTML = -1 != userAgent.indexOf("Windows");
PrintWriter out;
String title = "Phone Servlet";
// Requesting userAgent can handle HTML (like Windows)
if (isHTML) {
// use the response object to set the content type
res.setContentType("text/html");
// use the response object to get a PrintWriter object
out = res.getWriter

...

thanks in advance..
trupti
 
Brian Glodde
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's one of the HTTP Request header fields.

This line if present gives the software program used by the original client. This is for statistical purposes and the tracing of protocol violations. It should be included. The first white space delimited word must be the software product name, with an optional slash and version designator. Other products which form part of the user agent may be put as separate words.
<field> = User-Agent: <product>+
<product> = <word> [/<version>]
<version> = <word>
Example:
User-Agent: LII-Cello/1.0 libwww/2.5

Taken directly from: Request Headers
[ May 03, 2002: Message edited by: Brian Glodde ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!