| Author |
Difference between getAttribute(string) and getParameter(String)
|
praveen kumar gowda
Greenhorn
Joined: Feb 20, 2012
Posts: 23
|
|
hi guys,
i come to know how get Parameter method works.....In that,
1)when we submit the form without fields value(empty form) ,will the value is null or empty?
please explain me about get Attribute method..i am not clearing of this..
|
 |
Sabarish Venkat
Ranch Hand
Joined: Jan 18, 2012
Posts: 133
|
|
1. When you use getParameter() method and send it as empty you will get Null pointer exception since null values are retrived.
And the difference between getParameter() and getAttribute() is ,In getParameter you can retrive the values of the form.
Say you have
In the above code you can see the name="user1" this the key for us to take the user name type by the user. In next page you can get it as
Now you will get the user name typed by user.
For getAttribute(),
If you have a string value in a page and you want to take it to next page that time we use getAttribute(). It will get the value from previous page as session
Say ,
Now in next page you will get the session as,
This is the difference ... Check the bold words for exact difference to say in one word
|
 |
 |
|
|
subject: Difference between getAttribute(string) and getParameter(String)
|
|
|