aspose file tools*
The moose likes Servlets and the fly likes What is the diff b/w getAttribute and getParameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "What is the diff b/w getAttribute and getParameter" Watch "What is the diff b/w getAttribute and getParameter" New topic
Author

What is the diff b/w getAttribute and getParameter

Chandra Bairi
Ranch Hand

Joined: Sep 12, 2003
Posts: 152
Can anyone tell me what exactly is the difference between getAttribute and getParameter? if possible please give an example
Thanks in advance


Thanks,
Shekar
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
They are completely different things. It has been discussed here several times. Search this forum or www.google.com


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Malli Raman
Ranch Hand

Joined: Nov 07, 2001
Posts: 312
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
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

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")
Sri Basavanahally
Ranch Hand

Joined: Oct 07, 2003
Posts: 75
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.


UP THE IRONS !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is the diff b/w getAttribute and getParameter