We will now see how to implement a login application using Java Servlet. Create a new Dynamic Web Application in Eclipse as described in the previous section. We will call this LoginServletApp:
- Right-click on the src folder under Java Resources for the project in Project Explorer. Select the New | Servlet menu option.
- In the Create Servlet wizard, enter package name as packt.book.jee_eclipse.book.servlet and class name as LoginServlet. Then, click Finish.
Figure 2.22: Create Servlet wizard
- The servlet wizard creates the class for you. Notice the @WebServlet("/LoginServlet") annotation just above the class declaration. Before JEE 5, you had to declare servlets in web.xml in the WEB-INF folder. You can still do that, but you can skip this declaration if you use proper annotations. Using WebServlet, we are telling the servlet container that...