The getRequestDispatcher() method in the servlet class takes the path of the JSP file as the argument.įinally, we’ll create the JSP page to display the result.Ĭreate a result.jsp file in the src/main/webapp/ directory and add the following lines. The servlet will forward the request and response to a JSP view. Here we publish our SelectLiquorServlet class under the name selectliquorservlet and map it into the URL pattern “/SelectLiqour”. In the javax servlet api version 3.0.1 we can use the annotation to insert the servlet name and the servlet URL into the servlet without using a deployment descriptor. There is also a similar method called doGet() that can be overridden to handle the GET requests. I have overridden the doPost() method to get the “Type” of liquor sent from the form submission done by the index.html and get the available list of brands from the getAvailableBrands() method. Servlets are Java classes which service HTTP requests and implement the interface. The SelectLiquorServlet class will accept the POST request from the form submission and invoke the doPost() method. Servlets are the Java programs that run on the Java-enabled web server or application server.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |