Reputation: 368
Is there a way to send parameters from servlet to jsp without redirecting the browser to that page?
RequestDispatcher disp = request.getRequestDispatcher("shoppingCart.jsp");
disp.forward(request, response);
Upvotes: 1
Views: 2931
Reputation: 8946
Well you can either set the attributes(used in case of internal communication with servlets or servlet to jsp or vice-versa) to the response object and forward the request you can achieve this as :
request.setAttribute("someKey","someValue");
You can also use the session scope to share the attributes between servlet and jsp like this:
Http session = request.getSession();
session.setAttribute("someKey","someValue");
Upvotes: 1
Reputation: 347
There can be one way as below:
RequestDispatcher disp = request.getRequestDispatcher("shoppingCart.jsp"+"?myParam=myValue");
disp.forward(request, response);
If you are fine with "GET" method then you can solve this problem with appended parameters.
Upvotes: 2