File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes getAttribute and getParameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "getAttribute and getParameter" Watch "getAttribute and getParameter" New topic

getAttribute and getParameter


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

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

Joined: Dec 11, 2004
Posts: 13410

The said documentation:

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

Joined: Jan 10, 2002
Posts: 63852


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.

Forum Bartender

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: getAttribute and getParameter
It's not a secret anymore!