Java Servlet annotations reference
- Details
- Written by Nam Ha Minh
- Last Updated on 27 June 2019   |   Print Email
The Servlet 3.0 specification defines a number of annotation types which can be used to declare servlets, filters, listeners, security constraints and other metadata within Java source files as an alternative mechanism to XML declaration in web deployment descriptor file (web.xml).
The following table lists all annotation types available in Servlet 3.0. Click on an annotation type to see its syntax, attributes description and code examples:
Annotation type | Equivalent XML elements in web.xml |
|
None |
|
<http-method-exception> |
|
<http-method> |
|
None |
|
<security-constraint> |
|
<filter>, <filter-mapping> |
|
<init-param> |
|
<listener> |
|
<servlet>, <servlet-mapping> |
All the annotation types listed in the above table are declared in the package javax.servlet.annotation.
Other Java Servlet Tutorials:
- Java Servlet Quick Start for beginners (XML)
- Java Servlet for beginners (annotations)
- Handling HTML form data with Java Servlet
- How to use Cookies in Java web application
- How to use Session in Java web application
- How to Handle Error in Web.xml for Java web applications
Comments