Adverts
I recently hit a little bit of a problem with a filter that I was using to catch dynamic content on this site. I switched it over from filtering on /* (which catches all pages) to filtering on *.jspx. The idea was that I could make the site faster by filtering fewer requests. The problem with a /* request is that it catches every last thing which can be a bit of a problem if the filter takes it's time to discover whether it should be processing the request it is currently dealing with.
All was going well until I remembered that I needed to catch *.jsf with this particular filter as well. I was under the impression that I had one shot at filtering but it would seem that I was wrong. It is possible to put multiple filter mapping elements in to the web.xml file that all point to the same filter. I presume the same works for servlets as well. This greatly improves the usefulness of filters in my eyes. Yes, filters are invaluable, but they could become difficult to configure due to the limited nature of the pattern matching in the url-pattern element. If I had to choose one thing to improve in the servlet specification it would be the url-pattern matching. We've had regular expressions in Java for a few releases now - I think it's about time they were used when matching requests.