The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

tempusfugit (144) [Avatar] Offline
#1
This section does not clearly explain the semantics of the filter configuration. Without further explanation the first mapping in question 3

<filter-mapping>
<filter-name>FilterOne</filter-name>
<url-pattern>/admin/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>

could be misinterpreted to mean:
invoke the filter on requests to the specified url-pattern
AND on requests using the forward dispatch

It needs to be stated that

<filter-mapping>
<filter-name>FilterOne</filter-name>
<url-pattern>/admin/*</url-pattern>
</filter-mapping>

actually implies

<filter-mapping>
<filter-name>FilterOne</filter-name>
<url-pattern>/admin/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>

but that once the dispatch element is used, all mapped dispatch methods must be explicitly specified. Otherwise it cannot be clear that by specifying only
<dispatcher>FORWARD</dispatcher>
the 'default' dispatch
<dispatcher>REQUEST</dispatcher>
is not included in the mapping.

The all inclusive example of section 7.4.2 does not make these facts clear. Something like the specification's example is needed:
"
<filter-mapping>
<filter-name>Logging Filter</filter-name>
<servlet-name>ProductServlet</servlet-name>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
would result in the Logging Filter NOT being invoked by client requests to the
ProductServlet, NOR underneath a request dispatcher forward() call to the ProductServlet,
BUT would be invoked underneath a request dispatcher include() call
where the request dispatcher has a name commencing ProductServlet."