The moose likes EJB and other Java EE Technologies and the fly likes getParameter,getAttribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "getParameter,getAttribute" Watch "getParameter,getAttribute" New topic


Bharadwaj Adepu
Ranch Hand

Joined: Dec 30, 2007
Posts: 99
Can anyone please explain in detail what is the Difference between getParameter() and getAttribute().

SCJP 1.5
Ankur Bohra

Joined: Jun 29, 2007
Posts: 19
getAttribute() returns an object so when ever we use a getAttribute() we have to cast the return type that is we have to convert it to the required type like string or int.getParameter always returns a string.

one more difference is where this 2 methods are used...getAttribute is used to get the values from the session and getParameter is used to get the values from the form.(html or a jsp file)

Sun Certified Java Programmer<br />Sun Certified Web Component Developer <br />National Stock Exchange Certification in Financial Market
I agree. Here's the link:
subject: getParameter,getAttribute
It's not a secret anymore!