• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

attributes and paramters

 
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
william kane
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
reply
    Bookmark Topic Watch Topic
  • New Topic