This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Difference between getAttribute and getParameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Difference between getAttribute and getParameter" Watch "Difference between getAttribute and getParameter" New topic
Author

Difference between getAttribute and getParameter

navmn mn
Greenhorn

Joined: Nov 30, 2004
Posts: 13
Hi

I am at present working on servlets, I am encountered an difficulty in differentiating b/w getAttribute and getParameter in servlets

I basicallly know
request.getAttribute("String") returns value in string

request.getParameter("String") returns an Object :roll:
I did not understand what type of object it returns

Thanks in advance
Naveen
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You've got it backwards.

GetParameter returns a String. It's what you use to retrieve form parameters from an HTTP post.

getAttribute(String) and setAttribute(String, Object) are what you use to bind object variables to a scope (request, session, or context) and retrieve them from another servlet or JSP.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Difference between getAttribute and getParameter
 
Similar Threads
what is the attribute in servlet ?
Assign String[][] to a Session Attribute
Difference between getParameter and getAttribute
JavaBeans and Servlets
difference between getParameter() and getAttribute()