You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
~~ Pattern 1
server.addFitler(AuthFilter.class, "url1", null);
~~ Pattern 2
var fh = FilterHolder(AuthFilter.class)
var fm = FilterMapping("url1");
server.addFitler(fh, fm);
I have tried server.addFitler(AuthFilter.class, null, null); without success. I can confirm the filter init() is executed, but url patterns configured in annotation are not triggered. I have also server.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?
The text was updated successfully, but these errors were encountered:
zcattacz
changed the title
How to register WebFilters whose urlPatterns have been pre-configured in annotation ?
How to register WebFilters whose urlPatterns have been set in annotation ?
Nov 25, 2024
@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.
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?
The text was updated successfully, but these errors were encountered: