• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What is the diff b/w getAttribute and getParameter

 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone tell me what exactly is the difference between getAttribute and getParameter? if possible please give an example
Thanks in advance
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They are completely different things. It has been discussed here several times. Search this forum or www.google.com
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Chandra Bairi:
Can anyone tell me what exactly is the difference between getAttribute and getParameter? if possible please give an example
Thanks in advance


getAttribute return type is Object while getParameter return type is String.
- Regards,
M.S.Raman
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and beyond their return type, the represent two completely separate and distinct 'namespaces'.

If you submit a form, then the form elements are available through the getParameter() method. There is no corresponding setParameter().

If you place something with setAttribute(), it's available through getAttribute().

If you submit a form that contains a field named "foo", then trying to access the value through request.getAttribute("foo") will not work. Similarly, if you previously used setAttribute("foo2", "Hello"), you cannot get the String "Hello" back out by using getAttribute("foo2")
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Attributes are variables used for sahring in an application. There are four "places" to store attributes. Request, Context, Session and pageContext(JSP).
Parameters like Mike mentioned are with respect to HTTP requests.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic