Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problems to pass new params with RequestDispatcher

843841Dec 8 2005 — edited Dec 10 2005
Hi all,

I'm having the following problem. I've got a html form submitting a few input fields(parameters) to a dispatcher servlet that uses a RequestDispatcher objec to forward the request to a Servlet taking care of the business logic. In this servlet I'm trying to add a
request.setAttribute
to the Request object. A RequestDispatcher is again forwarding the request to a JSP page to output the result. My JSP page successfully outputs the parameters from the html form however the attribute I added in my business logic servlet doesn't seem to have been added.
This is the code from my business logic servlet where I'm adding a new attribute.

request.setAttribute("total","10");
RequestDispatcher router = request.getRequestDispatcher("/result.jsp");
router.include(request, response);

In my JSP I'm outputing my parameters the following way
String a = request.getParameter("formfield1");
String b=request.getParameter("total");

out.println("value of " +a);
out.println("value of " +b);

I actually also used the request.getParameterNames() to see which attributes were included in the request and all attributes were there except the one I add in my servlet.

If anyone can shed some light over this annoying problem, Pls let me know
Many thanks
Erik
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 7 2006
Added on Dec 8 2005
2 comments
441 views