Java Reference
In-Depth Information
HttpServletResponse res = (HttpServletResponse)response;
public void init(FilterConfig config) throws ServletException {
startHour = Integer.parseInt(config.getInitParameter("starthour"));
endHour = Integer.parseInt(config.getInitParameter("endhour"));
In Listing 3-42 the doFilter implements the logic for time-based access to the eIn-
sure application. In this case only, the preprocessing of the incoming request is carried
out to check whether the scheduled office hour's window has expired for the day. If so,
the user is redirected to a downtime notice page. Otherwise, the next filters in the chain
(if any) are executed. Finally, the target servlet and page controllers will be executed.
Note that the official business hours are configurable. The filter is registered in web.xml , as
shown in Listing 3-43, along with various parameters and a URL mapping. In this case,
this filter intercepts all requests ending with .do and heading toward the front controller.
This solution is highly reusable and based on Java servlet standards. It can be used even
without Spring MVC support because the web container is responsible for managing the
Listing 3-43. web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns=""
Search WWH ::

Custom Search