With Guice-servlet we can easily do servlet mapping like this: filter(*.jsp).through(MyFilter.class)
However could anyone tell me how can i map a filter to a servlet?
<filter-mapping>
<filter-name>Reporter</filter-name>
<servlet-name>SomeServletName</servlet-name>
</filter-mapping>
Thanks
That is not possible using Guice, as far as I can tell. You can serve URLs or filter URLs, but you cannot bind a filter to a specific servlet.
However if your servlet requires a particular processing of the request, maybe it might even be clearer to just do that call in code, instead of configuration? Filters are good if you need request processing that's used across many (all) servlets; if you need something specific to a particular servlet, you might be better off just calling the logic in question from you code.