In this section, we shall create a servlet to process the AJAX request and send a server response. A servlet represents the Controller facet of the Model View Controller (MVC) design pattern; the JSP page represents the View facet. Go to File | New | Other and in the New wizard, expand Web and select Servlet. Click on Next as shown in the following screenshot:
In Create Servlet,
select the project EclipseAjax in which you want to create a servlet, select the Source folder as /EclipseAjax/src
, specify a Java package name as ajax.servlet
and a Class name as FormServlet. A servlet extends the javax.servlet.http.HttpServlet
class. Click on Next as shown in the following screenshot:
The URL mappings get specified as /FormServlet, which is based on the servlet name. Click on Next as shown in the following screenshot:
Select the default Modifiers, Interfaces, and method stubs, which include the doGet and doPost by default. Click on Finish as shown in the following screenshot...