I have a suggestion regarding your code - just a minor change for greater efficiency. You are parsing the extensions
string over and over againg for every request, although it could be done just once, at filter initialization. Besides, if you put all the extensions into a map, you would be able to find out if the requested resource is static simply by doing a lookup.
private Map excludedExtensionsMap = new HashMap();
public void init(FilterConfig cfg) throws ServletException {
String extensions = cfg.getInitParameter("ExcludedExtensions");
if (extensions != null) {
StringTokenizer st = new StringTokenizer(extensions, ",");
while (st.hasMoreTokens()) {
excludedExtensionsMap.put(st.nextToken().trim(), ""); // only the key matters here
}
}
}
// in doFilter()
boolean isStaticResource = false;
String path = request.getServletPath();
int pos = path.lastIndexOf(".");
if (pos >= 0) {
String ext = path.substring(pos + 1);
isStaticResource = excludedExceptionsMap.containsKey(ext);
}
// the rest of your filter logic
Don't get me wrong: this piece of code alone won't win you any noticeable gain in performance, but I am just making a point here: small code optimizations here and there can add up to substantial amounts of saved processor ticks.