Filtering Requests and Responses
A filter is an object that can transform the header and content (orboth) of a request or response. Filters differ from web components in thatfilters usually do not themselves create a response. Instead, a filter provides functionality thatcan be “attached” to any kind of web resource. Consequently, a filter shouldnot have any dependencies on a web resource for which it is actingas a filter; this way, it can be composed with more thanone type of web resource.
What Is a Servlet?
A servlet is a Java programming language class used to extend thecapabilities of servers that host applications accessed by means of a request-response programming model.Although servlets can respond to any type of request, they are commonly usedto extend the applications hosted by web servers. For such applications, Java Servlettechnology defines HTTP-specific servlet classes.
The javax.servlet and javax.servlet.http packages provide interfaces and classes for writing servlets.All servlets must implement the Servlet interface, which defines lifecycle methods. When implementing ageneric service, you can use or extend the GenericServlet class provided with the JavaServlet API. The HttpServlet class provides methods, such as doGet and doPost, for handlingHTTP-specific services.
参照:http://docs.oracle.com/javaee/6/tutorial/doc/bnafe.html
http://docs.oracle.com/cd/B32110_01/web.1013/b28959/toc.htm
因为内容比较多,以后留着看