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