Which are true about filters? (Choose all that apply.)
A. | A filter can act on only the request or response object, not both. | |
B. | The | |
C. | The | |
D. | The only way a filter can be invoked is through a declaration in the DD. | |
E. | The next filter in a filter chain can be specified either by the previous filter or in the DD. |
Which are true about declaring filters in the DD? (Choose all that apply.)
A. | Unlike servlets, filters CANNOT declare initialization parameters. | |
B. | Filter chain order is always determined by the order the elements appear in the DD. | |
C. | A class that extends an API request or response wrapper class must be declared in the DD. | |
D. | A class that extends an API request or response wrapper class is using the Intercepting Filter pattern. | |
E. | Filter chain order is affected by whether filter mappings are declared via |
Given the class UserRequest is an implementation of HttpServletRequest, and given that this method in an otherwise properly defined Filter
implementation:
20. public void doFilter(ServletRequest req, 21. ServletResponse response, 22. FilterChain chain) 22. throws IOException, ServletException { 23. HttpServletRequest request = (HttpServletRequest) req; 23. HttpSession session = request.getSession(); 25. Object user = session.getAttribute("user"); 26. if (user != null) { 27. UserRequest ureq = new UserRequest(request, user); 28. chain.doFilter(ureq, response); 29. } else { 30. RequestDispatcher rd = request.getRequestDispatcher("/login.jsp"); 31. rd.forward(request, response); 32. } 33. }
Which is true?
A. | An exception will always be thrown if line 31 executes. | |
B. | Line 28 is invalid because | |
C. | This line: | |
D. | This method does not properly implement | |
E. | None of the above. |
Given a partial deployment descriptor:
11. <filter> 12. <filter-name>My Filter</filter-name> 13. <filter-class>com.example.MyFilter</filter-class> 14. </filter> 15. <filter-mapping> 16. <filter-name>My Filter</filter-name> 17. <url-pattern>/my</url-pattern> 18. </filter-mapping> 19. <servlet> 20. <servlet-name>My Servlet</servlet-name> 21. <servlet-class>com.example.MyServlet</servlet- class> 22. </servlet> 23. <servlet-mapping> 24. <servlet-name>My Servlet</servlet-name> 25. <url-pattern>/my</url-pattern> 26. </servlet-mapping>
Which is true? (Choose all that apply.)
A. | The file is invalid because the URL pattern | |
B. | The file is invalid because neither the servlet name nor the filter name is allowed to contain spaces. | |
C. | The filter | |
D. | The filter | |
E. | The file is invalid because the |
Which about filters are true? (Choose all that apply.)
A. | Filters may be used to create request or response wrappers. | |
B. | Wrappers may be used to create request or response filters. | |
C. | Unlike servlets, all filter initialization code should be placed in the constructor since there is no | |
D. | Filters support an initialization mechanism that includes an | |
E. | A filter’s | |
F. | When calling | |
G. | A filter’s |
Which are true about the servlet Wrapper classes? (Choose all that apply.)
A. | They provide the only mechanism for wrapping | |
B. | They can be used to decorate classes that implement | |
C. | They can be used even when the application does NOT support HTTP. | |
D. | The API provides wrappers for | |
E. | They implement the Intercepting Filter pattern. | |
F. | When you subclass a wrapper class, you must override at least one of the wrapper class’s methods. |