Hi, On 29.09.2010 22:00, Ian Boston wrote: > Hi, > Is it possible to register a filter before the SlingMainServlet ?
Short answer: No. Longer answer: The SlingMainServlet (or actually the SlingRequestProcessorImpl these days) is controlling the execution of the filters and those are only called once the SlingHttpServletRequest and ..Response objects have been properly set up including resource and script to be called. > > I can register a filter via the extended http service (PAX Web WebContainer > in my case) but I cant get the filter to bind to the SlingMainServlet, IIUC > because I cant get hold SlingMainServlets HttpContext. If you register a filter with the servlet container (such as when using the PAX extender or the Felix extender) you run outside of Sling and thus don't have access to the Sling request processing functionalities. Of course, you can still get access to Sling's ServletContext provided by the SlingMainServlet because this is registered as an OSGi service. And for now, I am not really fond of exposing this. But yes, the OSGi HttpContext instance used by the SlingMainServlet is private to the SlingMainServlet. > > For background > There are 2 filters I want to register. A caching filter and a GZip filter. As for GZip there is such a filter in the Simple Demo Sample [1]. This filter registers as high priority under the Sling Umbrella. [1] https://svn.apache.org/repos/asf/sling/trunk/samples/simple-demo/src/main/java/org/apache/sling/sample/filter/ZipFilter.java Regards Felix
