Win a copy of Spark in Action this week in the Open Source Projects forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can anybody please tell me what is dufference between request.getAttribute & request.getParameter?
PLease.
Thank you.
Pras
 
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Uh oh, we're definitely being carded. Here, show him this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic