Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
    Bookmark Topic Watch Topic
  • New Topic

difference between attributes and parameters?

 
amrit pal
Greenhorn
Posts: 1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Report post to moderator
what is the difference between request.getAttribute and request.getparameter methods?
 
Greg Charles
Sheriff
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
This question has come up often enough that it now has an entry in the ServletsFaq.
 
    Bookmark Topic Watch Topic
  • New Topic