![]() ![]() 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. Example: Defining the matching template class. You can modify them while creating the Java API. The servlet will forward the request and response to a JSP view. Creating the Component Java API This works in exactly the same way as described in Creating Java API for a Web Component, except that the static files are loaded from your project. 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. The SelectLiquorServlet class will accept the POST request from the form submission and invoke the doPost() method. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |