[ Team LiB ] Previous Section Next Section

Workshop

The Workshop is designed to help you review what you have learned and help you to further increase your understanding of the material covered in this hour.

Quiz

1:

Does a filter need to be thread-safe?

2:

What is the purpose of the wrapper classes?


Answers

A1:

A filter may need to be thread-safe. A container creates only one instance of a filter to service resources and will reuse that filter for many requests. Filters should be designed to handle concurrent requests.

A2:

Wrapper classes can save you time by providing a prebuilt class that implements the appropriate interfaces so that you can adapt a request to a servlet. The four wrapper classes are ServletRequestWrapper, ServletResponseWrapper, HttpServletRequestWrapper, and HttpServletResponseWrapper.


Activity

Using the sendRedirect method in an HttpServletResponse object, write a filter that redirects requests for a page at a URL to another location.

    [ Team LiB ] Previous Section Next Section