File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes what is differnce between request.getAttribute & request.getParameter? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "what is differnce between request.getAttribute & request.getParameter?" Watch "what is differnce between request.getAttribute & request.getParameter?" New topic
Author

what is differnce between request.getAttribute & request.getParameter?

Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186
Hi,
Can anybody please tell me what is dufference between request.getAttribute & request.getParameter?
PLease.
Thank you.
Pras


********Deserve Before You Desire********
vijay saraf
Ranch Hand

Joined: Jan 08, 2005
Posts: 141
you will always get string from getParameter,where as getAttribute gives you Object that may be any java object.
more than this i can't say.


Thanks
Vijay Saraf.
Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186
hi ,
thank you for reply,
But then if I want to set request parameter into my action class, how to set it?
how to set request parameter into action class ?
Please reply..
Thank you.
pras
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
There is another difference:

You can both set and get attributes in your action class. With parameters, you can't set them, but only get them.

Parameters can come from one of the following:

1-Strings passed in the query string. exmple:
http://mycompany.com/myapp/myAction.do?foo=xyz&bar=abc

2-Strings passed by submitting a form. example:

<html:form action="/myAction" >
<html:text property="foo" />
<html:text property="bar" />
<html:submit property="submitButton" />
</html:form>

In both cases, request.getParameter("foo") and request.getParameter("bar") will yield results.
[ August 02, 2006: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
 
wood burning stoves
 
subject: what is differnce between request.getAttribute & request.getParameter?