• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between getParameter and getAttribute

 
Jahnavi Kondapaneni
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can anybody explain me the difference between getParameter and getAttribute functions.
Thanks in advance.

Regards,
Janu
 
akhilesh pandey
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getParmeter() returns a String, whereas getAttribute() returns an Object. Remember always to cast the object to the required type, when using getAttribute().
 
Kunal Jag
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Regards,
 
Jahnavi Kondapaneni
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic