Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
118
Chapter 5 Accessing the Standard CGI Variables
REMOTE_HOST
REMOTE_HOST
 indicates the fully qualified domain name (e.g., 
white 
house.gov
) of the client that made the request. The IP address is 
returned if the domain name cannot be determined. You can access this 
variable with 
request.getRemoteHost()
.
REMOTE_USER
If an 
Authorization
 header was supplied and decoded by the server 
itself, the 
REMOTE_USER
 variable gives the user part, which is useful 
for session tracking in protected sites. Access it with 
request.get 
RemoteUser()
. For decoding 
Authorization
 information directly in 
servlets, see Section 4.5 (Restricting Access to Web Pages).
REQUEST_METHOD
This variable stipulates the HTTP request type, which is usually 
GET
 or 
POST
 but is occasionally 
HEAD
, 
PUT
, 
DELETE
, 
OPTIONS
, or 
TRACE
. Servlets 
rarely need to look up 
REQUEST_METHOD
 explicitly, since each of the 
request types is typically handled by a different servlet method (
doGet
, 
doPost
, etc.). An exception is 
HEAD
, which is handled automatically by 
the 
service
 method returning whatever headers and status codes the 
doGet
 method would use. Access this variable by means of 
request.getMethod()
.
SCRIPT_NAME
This variable specifies the path to the servlet, relative to the server's root 
directory. It can be accessed through 
request.getServletPath()
.
SERVER_NAME
SERVER_NAME
 gives the host name of the server machine. It can be 
accessed by means of 
request.getServerName()
.
SERVER_PORT
This variable stores the port the server is listening on. Technically, the 
servlet equivalent is 
String.valueOf(request.getServerPort())
, 
which returns a 
String
. You'll usually just want 
request.getServer 
Port()
, which returns an 
int
.
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved