I need to pass the productid value from one servlet to the other. My productid value is a hyperlink and when the user clicks on the productid link it needs to call another servlet which has its corresponding description.
How do I pass values between servlets ??? Can anybody please help.
My productid value is a hyperlink and when the user clicks on the productid link it needs to call another servlet which has its corresponding description.
Basically hyperlinks serve as GET request. So what you can do is to append the parameter, say productid to your href location seperated by '?'
It should look like
<a href = "/servlet1?product_id=value">click</a>
And from the servlet1 you override doGet() and inside you code request.getParameter("product_id"); Then do your logic.
Hope this is what you expected, if not give more details.
Nikhil Kanjulli Menon.
ford Darcy Jr
Joined: Jan 26, 2005
Thanks a lot...but when I actually hardcode the productid value (just the way u mentioned) I am able to get the values. But when I reference it as productid ie <A HREF=servlet1?productid=productid>I am not getting any values. My application basically has to display the product details based on the productid which the user clicks.
Joined: Nov 22, 2004
I guess you are using a jsp view, you can do it efficiently this way