Difference between request.getParameter and request.getAttribute?
4 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Radhika_R
Posted On:   Thursday, December 28, 2006 07:13 AM

What is the difference between request.getParameter and request.getAttribute?

Re: Difference between request.getParameter and request.getAttribute?

Posted By:   ABHISHEK_SHRIVASTAVA  
Posted On:   Wednesday, January 17, 2007 02:55 AM

Hi....
hetParameter() is used to get the values of the field entered in the jsp page....
while getAttribute() is used to get the attribute values set in the request,session or application scopes.For using getAttributes() u will need to set the attribute name & value for a particular request like..


request.setAttribute("COLLECTION_NAME",collection_value);
(Assume collection_value is a ArrayList containing values)

and u can write getAttribute() method on the jsp page to get the attribute value which was set...like

ArrayList myAttribute=request.getAttribute("COLLECTION_NAME");

now u can iterate through ur arraylist values and display on the page using a for loop or logic:iterate tag...


Please notice that getAttribute() returns Object and u need to typecast it as accordingly.


Good luck....
Abhishek

Re: Difference between request.getParameter and request.getAttribute?

Posted By:   ABHISHEK_SHRIVASTAVA  
Posted On:   Wednesday, January 17, 2007 02:53 AM

Hi....
getParameter() is used to get the values of the field entered in the jsp page....
while getAttribute() is used to get the attribute values set in the request,session or application scopes.For using getAttributes() u will need to set the attribute name & value for a particular request like..


request.setAttribute("COLLECTION_NAME",collection_value);
(Assume collection_value is a ArrayList containing values)

and u can write getAttribute() method on the jsp page to get the attribute value which was set...like

ArrayList myAttribute=request.getAttribute("COLLECTION_NAME");

now u can iterate through ur arraylist values and display on the page using a for loop or logic:iterate tag...


Please notice that getAttribute() returns Object and u need to typecast it as accordingly.


Good luck....
Abhishek

Re: Difference between request.getParameter and request.getAttribute?

Posted By:   ABHISHEK_SHRIVASTAVA  
Posted On:   Wednesday, January 17, 2007 02:50 AM

Hi....
hetParameter() is used to get the values of the field entered in the jsp page....
while getAttribute() is used to get the attribute values set in the request,session or application scopes.For using getAttributes() u will need to set the attribute name & value for a particular request like..


request.setAttribute("COLLECTION_NAME",collection_value);
(Assume collection_value is a ArrayList containing values)

and u can write getAttribute() method on the jsp page to get the attribute value which was set...like

ArrayList myAttribute=request.getAttribute("COLLECTION_NAME");

now u can iterate through ur arraylist values and display on the page using a for loop or logic:iterate tag...


Please notice that getAttribute() returns Object and u need to typecast it as accordingly.


Good luck....
Abhishek

Re: Difference between request.getParameter and request.getAttribute?

Posted By:   WarnerJan_Veldhuis  
Posted On:   Thursday, December 28, 2006 08:47 AM

The getParameter() reads a value of the URL or PostData. For example: http://www.jguru.com/blah.jsp?foo=bar. getParameter("foo") will return a String "bar". getAttribute() is to read an object from the request, that has been put there, by for example an Action in Struts, or a Servlet.
About | Sitemap | Contact