I am pretty new in JSP and Servlet development and I have to do the following thing:
I have a JSP page that contains a JQuery button element.
<th width = "8.33%">
<form action="salwf.do" method="post">
<button name="status" value="Accept" class="acceptButton">ACCEPT BUTTON</button>
<button name="status" value="Cancel" class="cancelButton">CANCEL BUTTON</button>
<button name="status" value="SAP" class="sapButton">SAP ICON BUTTON</button>
</form>
</th>
As you can see I put this button element into a form. Each button have a property named status for all buttons and a specific value for each button (Accept for the first button, Cancel for the second button and Sap for the third button).
Ok, now I want to submit this form to the Servlet that handle the page that contains the form. This page have the following URL:
http://localhost:7001/edi-mon/salwf.do
and this is the servlet configuration into the web.xml file (Servlet definition and Servlet URL mapping):
<servlet>
<servlet-name>salwf</servlet-name>
<servlet-class>it.sistinf.ediweb.monitor.servlets.Salwf</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>salwf</servlet-name>
<url-pattern>/salwf.do</url-pattern>
</servlet-mapping>
Then I have the Salwf class that implement the HttpServlet interface and that handle this JSP page.
So this Servlet have also to handle the post of the previous form, to do this I have implement the doPost() method inside this class, in this way:
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String status = request.getParameter("status");
}
So I hopped to retrieve the value of the status name of the JQuery clicked button but it didn't work.
When debugging the application I tried to click on the buttons but I never entered into the doPost() method and so I can't retrieve the value of the status request paramether.
Why? What am I missing? How can I fix this issue?