Submit form to Servlet CQ5
I created a Servlet call ShippingDetailsServlet.java and deployed it. I need to submit a HTML form to it. I am not sure what path I should put in the form action. Below is the form.
<form action="/services/mycompany/ShippingDetailsServlet" method="post"> Country: <input type="text" name="country" value="au"><br> Quantity: <input type="text" name="quantity" value="1"> <cq:include path="./submit" resourceType="foundation/components/form/submit" /> </form>
Please let me know what path should I give for the form action so that it can be submitted to the Servlet.
Below is the Servlet.
package mycompany.servlets;
import org.apache.felix.scr.annotations.Properties; import org.apache.felix.scr.annotations.Property; import org.apache.felix.scr.annotations.sling.SlingServlet; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.SlingHttpServletResponse; import org.apache.sling.api.servlets.SlingAllMethodsServlet; import javax.servlet.ServletException; import java.io.IOException; import java.io.PrintWriter; @SlingServlet( paths={"/services/mycompany/"} ) @Properties({ @Property(name="service.pid", value="mycompany.ShippingDetailsServlet",propertyPrivate=false), @Property(name="service.description",value="Shipping details servlet", propertyPrivate=false), @Property(name="service.vendor",value="mycompany", propertyPrivate=false) }) public class ShippingDetailsServlet extends SlingAllMethodsServlet { @Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { //Do something fun here } @Override protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { //Do something fun here PrintWriter out = response.getWriter(); out.println("Hello"); } }