Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between getAttribute and getParameter

 
navmn mn
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic