Open zcattacz opened 2 days ago
@zcattacz you can use the standard servlet api annotations to register your servlets, filters and listeners with jetty too. Just make sure that you have enabled the ee10-annotations
module.
If you actually do want to switch to using embedded setup rather than via annotations have a look at https://jetty.org/docs/jetty/12/programming-guide/server/http.html#handler-use-servlet. There's some examples to show you how to define servlets/filters etc and add them to your ServletContextHandler/WebAppContext
.
Jetty Version Jetty 12
Jetty Environment
ee10
Java Version JDK17
Question I am embedding Jetty 12 into a existing standard spring 6 project, which has been developed and run under tomcat. The login filter is created with annotation:
This was automatically registered in Tomcat10. so I never thought of how these can be manually added to a ServletContext. With jetty, the examples I can are like below:
I have tried
server.addFitler(AuthFilter.class, null, null);
without success. I can confirm the filterinit()
is executed, but url patterns configured in annotation are not triggered. I have alsoserver.addFitler(AuthFilter.class, "/", null);
which is triggered for every request.I wonder if there is any way to register a @WebFitler annotated filter class with url patterns already set in annotation, without specifying its pattern again in addFitler call?