20.2 How to Read the
Value of a HTTP Header?
To
read the value of a HTTP header, you need to use a server-side
technology like ASP, Java Servlet, JSP, Perl, PHP, etc.
For
example, to read the user-agent header value and store it into a
variable uaheader with JSP, use the following code:
String
uaheader = request.getHeader("user-agent");
For
ASP (VBScript), use the following code to read the user-agent header
value:
dim
uaheader uaheader = Request.ServerVariables("http_user_agent")
For
ASP (JScript), use the following code to read the user-agent header
value:
var
uaheader = Request.ServerVariables("http_user_agent");
For
PHP, use the following code to read the user-agent header value:
$uaheader
= $_SERVER["HTTP_USER_AGENT"];
Feedback Form ( ExpandCollapse)
|