JSP and Servlet programming
i have two buttons of type "sumbit" in my JSP page. I made a form method =post to redirect to a servlet. Its something like this
<form method="post" action="updateCart">
<input type="submit" name="add_to_cart" value="Add2Cart">
<input type="submit" name="checkout" value="checkout"></p>
when some one clicks any of the submit button the servlet will read the value and depending on the button value obtained i want to perform next action.
My Servlet code is like this
1)String add_to_cart = null;
2)String checkout = null;
4)checkout = request.getParameter("checkout").toString();
.... more code
The problem is If i click add to cart button error is with line 4. if i click checkout error is with line 3.
If I comment any of the method(i.e., if i either put only line 3 and remove all checkout information or if i put only checkout information and remove add_to_cart information) the code is working, all the redirections caliculations are happening.
please let me know how to check which button is clicked in a servlet if i have more than one button of type submit in my jsp page.