Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java Servlets
Expertise: Beginner
Oct 15, 1999

Servlet Attributes and Parameters

Question:
When a request message is processed through the HttpServlet doGet method, who sets the parameters and attributes for the HttpServletRequest argument? And what is the difference between an attribute and a parameter?

Answer:
Client requests are passed on to a servlet through the Web server's servlet engine. The servlet engine packages the request into a ServletRequest object, through which request attributes and parameters can be extracted.

The HttpServlet class examines the request and repackages it as an HttpServletRequest before dispatching it to one of its "do" methods, such as doGet. Attributes provide a means for the Web server to give a servlet extra information about a request. They do not represent data that was sent directly from the client.

Parameters are akin to function arguments. They are name value pairs transmitted by the client and interpreted by the servlet.

For example, the values submitted through an HTML form would be passed as parameters that could be accessed through the HttpServletRequest argument to doGet.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap