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

request.getParameter Vs request.getAttribute

Ann Kurian

Joined: May 02, 2005
Posts: 2
I am kind of new here..and I love browsing this forum as I am still a biginner in servlet programming.Please help !
Could you please explain to me the difference btn Request.getParameter and request.getAttribute. In one of the programs I am trying to write I want to pass a value (id) from the servlet to a parent class. I can set it up as request.setAttribute(�id�, 1). But in the parent java class , (which I cannot change) it uses the value id as request.getParameter(id). I am unable to set up the variable as request.setParameter in the Java class. Could anyone please explain how to solve this�
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

getParameter is what you use to retrieve HTTP form parameters from a webpost and is read only.

set and getAttribute are used for binding objects to request, session, or context scope.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ann Kurian

Joined: May 02, 2005
Posts: 2
I agree. Here's the link:
subject: request.getParameter Vs request.getAttribute
It's not a secret anymore!