2

I want to filter all requests to my jersey servlet so I do this:

<filter-mapping>
   <filter-name>jersey</filter-name>
   <url-pattern>*</url-pattern>
</filter-mapping>

Unfortunatly, this has the side-effect of catching the dev console (http://localhost:8888/_ah/admin)

Is there a way I can exclude paths matching "/_ah/*" from the filter?

Or perhaps a better way to achieve the same thing?

matt burns
  • 24,742
  • 13
  • 105
  • 107
  • 1
    Have a look at this: http://stackoverflow.com/questions/3125296/can-i-exclude-some-concrete-urls-from-url-pattern-inside-filter-mapping – adarshr May 17 '12 at 10:59

2 Answers2

4

Thanks to the suggestion by @adarshr I started to look into extending the Jersey filter servlet so that I could skip certain paths. It was then I realised that it already supports paths to ignore as an init param.

<init-param>
    <param-name>com.sun.jersey.config.property.WebPageContentRegex</param-name>
    <param-value>/(js|css|(WEB-INF/jsp)|_ah)/.*</param-value>
</init-param>

(I was already even using it after pasting in the code from somewhere without reading it!)

matt burns
  • 24,742
  • 13
  • 105
  • 107
1

I would advice to have a servlet which you can use to configure all the filter mappings. So servlet would handle all the queries and reroute them accordingly, as web.xml doesn't allow regex mapping.

We use guiceServlet from Google Guice to do the same thing:

Then in configureServlets we do the following:

  serveRegex("/(?!_ah).*").with(JerseyGateway.class);

There are a number of suggestions on the topic you can look at here.

Community
  • 1
  • 1
husayt
  • 14,553
  • 8
  • 53
  • 81