File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes request attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "request attribute" Watch "request attribute" New topic

request attribute

sweety singh

Joined: Dec 04, 2006
Posts: 13
what is the difference between the request.getAttribute() and request.getParameter()? and when to use each of them
Mahesh Desai
Ranch Hand

Joined: Apr 04, 2007
Posts: 76
By using request.getParameter() we can retrive the values that are submitted by an HTML form or that was included in a query string in URL. If we are using servlet code to set an attribute, we have to use the request.setAttribute("xxx","zzz") to set it and request.getAttribute("xxx") to retrieve it. The getAttribute() method always returns an Object and the getParameter() method always returns a String.


SCJP 1.4 | SCWCD 1.4 | SCBCD 1.3 | SCEA Part I - In Progress
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 10032

I think your question should be what is the difference between a parameter and an attribute. Once you understand them clearly, you will understand the ways to manipulate them. Look at HFSJ for the 5th chapter. Your question is answered there more clearly!

SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
I agree. Here's the link:
subject: request attribute
It's not a secret anymore!