Forums Register Login

attributes and paramters

+Pie Number of slices to send: Send
Hi,
What is the difference between the request attribute and request parameter?
I have found that a request attribute is being created for every request parameter i.e when i have form that has parameters of name id and password
I am able to access the values using request.getAttribute("Id"),request.getAttribute("Password"),request.getParameter("id"),request.getParameter("password") in tomcat.Why is it needed?
Thanks in advance
William
+Pie Number of slices to send: Send
It's not needed.

On its own, no container will automatically place request parameters in scoped variables (attributes, as you called them). If this is happening, something else is responsible. Are you using a framework such as Struts?
[ July 28, 2005: Message edited by: Bear Bibeault ]
+Pie Number of slices to send: Send
To answer:

What is the difference between the request attribute and request parameter?



Request parameters are the result of submitting an HTTP request with a query string that specifies the name/value pairs, or of submitting an HTML form that specifies the name/value pairs.

The name and the values are always strings.

Request attributes (more correctly called "request-scoped variables") are objects of any type that are explicitly placed on the request object via a call to the setAttribute() method. They are retrieved in Java code via the getAttribute() method and in JSP pages with Expression Language references.
[ July 28, 2005: Message edited by: Bear Bibeault ]
+Pie Number of slices to send: Send
 

Originally posted by Bear Bibeault:
To answer:



Request parameters are the result of submitting an HTTP request with a query string that specifies the name/value pairs, or of submitting an HTML form that specifies the name/value pairs.

The name and the values are always strings.

Request attributes (more correctly called "request-scoped variables") are objects of any type that are explicitly placed on the request object via a call to the setAttribute() method. They are retrieved in Java code via the getAttribute() method and in JSP pages with Expression Language references.

[ July 28, 2005: Message edited by: Bear Bibeault ]



Thanx Bear Bibeault,
I am now clear with the difference b/n attributes and parameters.Yes i am using Struts.Do you think its the work of Struts to have this attributes added?
Regards,
William
Do the next thing next. That’s a pretty good rule. Read the tiny ad, that’s a pretty good rule, too.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1230 times.
Similar Threads
HttpServletRequestWrapper Struts
Implicit Objects doubt!
How to Pass parameters in struts
Getting values from id attribute in a servlet
Fields in JSP Page is containing the value from the previous load of the page
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 01:40:42.