Servlet can be create with the help of @WebServlet Servlet annotation. This will not require any entry the deployment descriptor web.xml file.
Annotation got introduced as part of servlet 3.0
Please find below list for some other annotations:
@WebInitParam This is to specify init param earlier used to define as part of <init-apram> tag.
@WebFilter: It helps us to declare a servlet filter.
@WebListener: It helps us to declare a WebListener
Servlet class needs to extends HttpServlet class and define @WebServlet on top of the class.
Below will be the content required in web.xml
Right click on the project and select Run As and then Run on Server to run application on Apache Tomcat.
Hit below url in browser to get an output.
http://localhost:8082/ServletDemo/login
OUTPUT
Specialist Master (Architect) with a passion for cutting-edge technologies like AEM (Adobe Experience Manager) and a proven track record of delivering high-quality software solutions.
📝 Blogs
javadoubts.com © All rights reserved