Filters can be used to implement ________, which is a common requirement in web applications.
- authentication
- authorization
- caching
- logging
Filters can be used to implement authorization, which is a common requirement in web applications.
A filter can alter the header information of a request or response by modifying the __________.
- HeaderFilter
- HeaderInterceptor
- HeaderModifier
- HeaderProcessor
A filter can alter the header information of a request or response by modifying the HeaderModifier.
The sequence of filters applied to a request is determined by the order of __________ in the web.xml file.
- filter-chain
- filter-mapping
- filter-order
- filter-sequence
The sequence of filters applied to a request is determined by the order of the elements in the web.xml file, specifically by the filter-order subelement.
For form submission with file upload, the __________ content type and the _______ method are used.
- GET
- application/x-www-form-urlencoded
- multipart/form-data
- text/plain
For form submission with file upload, the multipart/form-data content type and the POST method are used. This allows for encoding binary data, such as file uploads, in the request.
To pass the request and response to the next entity in the chain, the filter uses the __________ method.
- continueChain()
- doFilter()
- doNext()
- passOn()
To pass the request and response to the next entity in the chain, the filter uses the doFilter() method.
In the deployment descriptor, the __________ tag is used to specify which requests are passed through a particular filter.
- filter-mapping
- filter-name
- servlet-mapping
- url-pattern
In the deployment descriptor, the url-pattern tag is used to specify which requests are passed through a particular filter.
The __________ object provides the filter with its configuration information.
- FilterChain
- FilterConfig
- HttpServletRequest
- ServletContext
The FilterConfig object provides the filter with its configuration information.
How do filters interact with different types of servlets and JSP pages?
- Filters can interact with both servlets and JSP pages in the same way.
- Filters can only interact with JSP pages, not servlets.
- Filters can only interact with servlets, not JSP pages.
- It depends on the filter configuration.
Filters can interact with both servlets and JSP pages in the same way, providing a unified mechanism for processing requests and responses in web applications.
What is the difference between filter chaining and servlet chaining?
- Filter chaining is sequential execution of multiple filters before the servlet is invoked.
- Filter chaining is used only for static resources.
- Servlet chaining is sequential execution of multiple servlets before the response is sent to the client.
- There is no difference.
Filter chaining involves the sequential execution of multiple filters before the servlet is invoked, allowing each filter to process the request or response. Servlet chaining involves the sequential execution of multiple servlets before the response is sent to the client.
Can a filter modify the request and response objects?
- Depends on servlet version
- No
- Sometimes
- Yes
Yes, a filter can modify the request and response objects before they reach the servlet or after they leave the servlet, providing a mechanism to pre-process or post-process the request and response.
How does the servlet container use the order of filter mappings in web.xml?
- To control servlet instantiation
- To determine the priority of filter execution
- To enforce security constraints
- To manage session attributes
The order of filter mappings in web.xml is used by the servlet container to determine the priority of filter execution. Filters are applied in the order in which they are declared in the web.xml file, allowing developers to control the sequence in which filters are invoked.
The return type of the method used to retrieve a servlet initialization parameter is _________.
- Integer
- Map
- Object
- String
The return type of the method used to retrieve a servlet initialization parameter is String.