File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes difference between attributes and parameters? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

difference between attributes and parameters?

amrit pal
Greenhorn

Joined: Aug 01, 2012
Posts: 1
what is the difference between request.getAttribute and request.getparameter methods?
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2833
    
  11

They are two different collections. The parameters are generally set by the framework when handling a GET request with parameters in the URL (e.g., http://myserver.com?id=5&name=amrit) or when a POST request contains parameters set through a form. The attributes are something the user has access to, so a servlet could do initial processing and set values to the request attributes, then forward to a JSP to be displayed. The JSP can read the attributes when building up the page. JSTL and the Expression Language make it especially easy to retrieve values from the request attributes.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60743
    
  65

Greg Charles wrote:The attributes are something the user has access to ...

I'm not sure what is meant by this, but "attributes" (more precisely known as scoped variables) are certainly not something that the end user has access to.
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2833
    
  11

D'oh! My brain said developer, but my fingers typed user. I meant that attributes are something you might set as you process a request, but parameters generally aren't.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60743
    
  65

This question has come up often enough that it now has an entry in the ServletsFaq.
 
 
subject: difference between attributes and parameters?
 
Similar Threads
difference between page and request
Priority Queue
diff b/w javax.rmi.* & java.rmi.* ?
Technology vs framework
difference between IOC and Dependency Injection