I have one jsp from which I am getting a string value in servlet1 using 'request.getParameter' I want to link servlet1 and servlet2 and send the string value which i have got in servlet1 to servlet2.
please help.
Many thanks in advance.
You need to set request attribute
In your servlet1.
request.setAttribute("attributeName",yourStringVAlue);
RequestDispatcher rd = request.getRequestDispatcher("yourServletPattern");
rd.forward(request,response);
In your Servlet2
String someName = (String)request.getAttribute("attributeName");
In Servlet 1 :
request.setAttribute("myAwesomeAttributeName",myAwesomeAttributeValue);
then recieve it in servlet 2 by
request.getAttribute("myAwesomeAttributeName");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With