CHAPTER 2: Building Web Applications Using Servlets and JSP 67
Data compression filters
Encryption filters
Image conversion filters
Logging and auditing filters
Configuring Servlet via Annotations
From Servlet 3.0 onward, servlets can be configured either via web.xml or using annotations or both.
Table 2-2 describes the annotations supported by a Servlet 3.0–compliant web container.
Table 2-2. Annotations for Configuring the Servlet
Annotation Description
@WebFilter Defines a filter in a web application
@WebInitParam Specifies init parameters to be passed to the servlet or the filter
@WebListener Annotates a listener to get events
@WebServlet Defines a component in a web application
@MultipartConfig Indicates that the request is of type mime/multipart
In the section that follows, you will develop a helloworld project in which you will configure the
servlet via annotations. Right-click the project helloworld, create a new servlet class, and give the
class name as HelloWorld, as shown in Figure 2-18. Click Next.
Figure 2-18. Creating a servlet