Two Laptop Bag
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Difference between getParameter and getAttribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Difference between getParameter and getAttribute" Watch "Difference between getParameter and getAttribute" New topic

Difference between getParameter and getAttribute

Jahnavi Kondapaneni
Ranch Hand

Joined: Jan 25, 2008
Posts: 56
Can anybody explain me the difference between getParameter and getAttribute functions.
Thanks in advance.

akhilesh pandey

Joined: Jun 03, 2008
Posts: 17
I think getParameter is a method where in the you get the things from Url. No where you set the paramter values to get it,but in getAttribute you need to first set the attribute values using setAttribute method.
Gopikrishna Kunisetty
Ranch Hand

Joined: Jun 12, 2008
Posts: 35
getParmeter() returns a String, whereas getAttribute() returns an Object. Remember always to cast the object to the required type, when using getAttribute().

- Krishna<br /> SCJP 1.4 SCWCD 5
Kunal Jag
Ranch Hand

Joined: Jun 08, 2008
Posts: 31
Newcomers to Web app development often get confused between attributes and parameters. Following are the two key differences between parameters and attributes:
1. Attributes are always set programmatically, while initialization parameters ( for example, servlet initialization and context initialization) are set declaratively in the DD file.
2. Also, there�s different in their APIs, for instance, the return type of parameters is String while that of Attributes is an Object.


Kunal Jaggi<br />Author of <a href="" target="_blank" rel="nofollow">"SCWCD Exam Guide"</a>, SCWCD 5 (exam 310-083 and 310-084), <a href="" target="_blank" rel="nofollow">McGraw-Hill</a><br /><a href="" target="_blank" rel="nofollow"></a><br /><a href="" target="_blank" rel="nofollow"></a>
Jahnavi Kondapaneni
Ranch Hand

Joined: Jan 25, 2008
Posts: 56
Thanks guys!!!
I agree. Here's the link:
subject: Difference between getParameter and getAttribute
It's not a secret anymore!