File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between getAttribute and getParameter
 
Similar Threads
JavaBeans and Servlets
Difference between getParameter and getAttribute
what is the attribute in servlet ?
difference between getParameter() and getAttribute()
Assign String[][] to a Session Attribute