• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setParameter() and setAttribute()

 
Brian Smith
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Folks,
Normally, getParameter() and setParameter() are used to retrieve information posted by a form using GET/POST.Information posted with form can be retrieved with getAttribute.BUT ONLY if the information is explicitly put in objects like request, pagecotext etc using "setAttribute", then we MUST use "getAttribute" NOT *getParameter". I believe information put in these objects with "setAttribute" and "setParameter" are different and eventhough are placed in the same object.Now my question is WHAT is the situation WHERE "setAttribute" is required instead of "setParameter"? and we can't use "setParameter" at all but "setAttribute"? I would appreciate if you could point out clearly.
thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no setParameter() method.

getParameter() is used to retrieve submitted parameter values, be they from a form submission or retrieved from the query string of a URL.

setAttribute() and getAttribute() are used to get and retrieve scoped variables from the page, request, session and application contexts.

They are completely different concepts.
 
Brian Smith
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,
Originally posted by Bear Bibeault:
There is no setParameter() method.

getParameter() is used to retrieve submitted parameter values, be they from a form submission or retrieved from the query string of a URL.

setAttribute() and getAttribute() are used to get and retrieve scoped variables from the page, request, session and application contexts.

They are completely different concepts.


So getParameter() can't be used to get the scoped variables? WHY? because there's not setParameter?

How is parameter different than attribute? specific situation each one is required? thanks.
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Carn Melon:

So getParameter() can't be used to get the scoped variables? WHY? because there's not setParameter?

Why do you need two methods to do the same action?


How is parameter different than attribute? specific situation each one is required? thanks.

parameters are String values bound to String names(keys), are set by the J2EE server, from the HTTP request sent by the browser.
An attribute can be any object bound to a String name(key), you have to explicitly bind it or unbind it.

Have a look at
J2EE API, a programmer's best friend
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic