This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JSP and the fly likes getAttribute and getParameter Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "getAttribute and getParameter" Watch "getAttribute and getParameter" New topic
Author

getAttribute and getParameter

Maureen
Greenhorn

Joined: Jun 17, 2005
Posts: 1
What is the difference of getAttribute and getParameter? and how to use them?


Thanks
Mishra Anshu
Ranch Hand

Joined: Sep 16, 2003
Posts: 224
Please refer to the documentation for detailed differences.

One of the differences is , in request.getParameter("var") method,
you get the parameter value of the variable "var" which was sent through the HTML page and return a String value.
But in case of the request.getAttribute(Object o) method, you get the attribute added for Object o as the return value. These value are not sent through some of the component on the HTML form rather in the jsp page which produced that particular HTML page must code it like -- request.setAttribute(name, value).

Hope it helps a bit.


"Ignorance is bliss"
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
As Mishra said, read the docs. There is no other better substitute.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The said documentation:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServletRequest.html


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56197
    
  13

"Maureen",

There aren't may rules that have been put into place here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: getAttribute and getParameter
 
Similar Threads
difference between getParameter() and getAttribute()
getParameter()
getParameter,getAttribute
Difference between getParameter() and getAttribute()
Pass parameter on URL to struts app?