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

getAttribute and getParameter

 
Maureen
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference of getAttribute and getParameter? and how to use them?


Thanks
 
Mishra Anshu
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please refer to the documentation for detailed differences.

One of the differences is , in request.getParameter("var") method,
you get the parameter value of the variable "var" which was sent through the HTML page and return a String value.
But in case of the request.getAttribute(Object o) method, you get the attribute added for Object o as the return value. These value are not sent through some of the component on the HTML form rather in the jsp page which produced that particular HTML page must code it like -- request.setAttribute(name, value).

Hope it helps a bit.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Mishra said, read the docs. There is no other better substitute.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Maureen",

There aren't may rules that have been put into place here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic