Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 3 of 5
<filter-mapping>
<filter-name>Image Filter</filter-name>
<servlet-name>ImageServlet</servlet-name>
</filter-mapping>
Now you can bind all servlets at once:
<filter-mapping>
<filter-name>Image Filter</filter-name>
<servlet-name>*</servlet-name> <!-- New -->
</filter-mapping>
This proves most useful when creating general rules like, "Execute a filter on all forwards to a servlet," which is written like this:
<filter-mapping>
<filter-name>Dispatch Filter</filter-name>
<servlet-name>*</servlet-name>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
Second, when writing a <servlet-mapping> or <filter-mapping>, you can now provide multiple match criteria in the same entry. A <servlet-mapping> previously supported just one <url-pattern> element. Now it supports more than one. For example:
<servlet-mapping>
<servlet-name>color</servlet-name>
<url-pattern>/color/*</url-pattern>
<url-pattern>/colour/*</url-pattern>
</servlet-mapping>
Likewise, a <filter-mapping> previously allowed just one <url-pattern> or one <servlet-name>. Now it supports any number of each:
<filter-mapping>
<filter-name>Multipe Mappings Filter</filter-name>
<url-pattern>/foo/*</url-pattern>
<servlet-name>Servlet1</servlet-name>
<servlet-name>Servlet2</servlet-name>
<url-pattern>/bar/*</url-pattern>
</filter-mapping>
Both these changes are syntactic sugar, but so be it. There's no reason we should program low carb.
Lastly, you can now place any legal HTTP/1.1 method name into an <http-method> element. As you may recall, the <http-method> element specifies the methods on which a <security-constraint> entry should apply. It's historically been limited to the seven standard HTTP/1.1 methods: GET, POST, PUT, DELETE, HEAD, OPTIONS, and TRACE. However, HTTP/1.1 allows for extension methods, and WebDAV is a popular technology using extensions. With Servlet 2.5, you
can now apply security constraints on any conceivable HTTP method name, standard or extension, including WebDAV methods like
LOCK, UNLOCK, COPY, and MOVE.
Just don't look for doLock() or doCopy() methods if you're writing a WebDAV servlet. You'll have to write your own service() method and peek at the request.getMethod() for dispatching. You just won't have to manage your own security, thanks to this change.
Servlet 2.5 eased a few restrictions around error handling and session tracking. With error handling, Servlet 2.5 removed
a rule dictating that error-handling pages configured with <error-page> could not call setStatus() to alter the error code that triggered them. The rule followed the argument that the job of an error page is to report each
error but not alter it. However, practical use has made clear that sometimes an error-handling page may be able to do something
more graceful than show an error, perhaps choosing instead to show an online help chat window to help the user resolve the
problem. The specification no longer prevents an error-page handler from producing a nonerror response.
Archived Discussions (Read only)