servlet-filters

Spring security custom filter called multiple times

我们两清 提交于 2020-08-22 04:48:47
问题 I have a custom logout filter called six times. Twice as soon I try to access the application, twice when I enter username/password and click on 'Login' and then twice again when I click on 'logout'. What am I doing wrong? Configuration: <http auto-config="true" use-expressions="true"> <intercept-url pattern="/admin/**" access="hasRole('ROLE_ADMIN_FUNCTIONS')" /> <intercept-url pattern="/**" access="hasRole('ROLE_USER')" /> <form-login login-page="/login" authentication-success-handler-ref=

Spring injection in Filter implementation mapped in web.xml

一曲冷凌霜 提交于 2020-07-16 09:21:21
问题 web.xml: <filter> <filter-name>myFilter</filter-name> <filter-class>com.mypackage.MyFilter</filter-class> </filter> <filter-mapping> <filter-name>myFilter</filter-name> <url-pattern>/myFilterPattern/*</url-pattern> </filter-mapping> MyFilter: public class MyFilter implements Filter { @Autowired InjectedBean someInjectedBean; However, when intercepting /myFilterPattern/* requests, someInjectedBean in MyFilter.doFilter(...) is still null, meaning it has not been injected. The same bean (

Relationship between Spring DispatcherServlet and Filters

血红的双手。 提交于 2020-06-12 09:14:00
问题 Spring MVC uses a DispatcherServlet to route control to an appropriate Controller. But where do filters fit into the flow? If I specify a filter to perform session management or authentication, will the filters always be called before DispatcherServlet? My confusion comes from the fact that they both specify a URL pattern. What happens if they both provide the same url pattern? 回答1: This is not really specific to Spring and Spring MVC. In general fitlers are always called before servlets.

doFilter called twice, intended behaviour?

…衆ロ難τιáo~ 提交于 2020-04-09 07:58:06
问题 I'm working through the Java EE servlet tutorial and tried the mood example. I noticed the doFilter is getting called twice, once the servlet call is in the chain and the second time it isnt. I added some printlns in the TimeOfDayFilter.java and in the MoodServlet.java to show this. TimeOfDayFilter.java: ... System.out.println("TimeOfDay before"); //added chain.doFilter(req, res); System.out.println("TimeOfDay after"); //added ... MoodServlet.java: ... response.setContentType("text/html

How filter chain invocation works?

a 夏天 提交于 2020-04-07 14:21:54
问题 I am trying to understand filter chaining.As defined in this question All filters are chained (in the order of their definition in web.xml). The chain.doFilter() is proceeding to the next element in the chain. The last element of the chain is the target resource/servlet. I am interested to know behind the scene in container that how container handles filter chaining.Can someone explain that how Filter chaining is handled inside container? 回答1: Each filter implements the javax.servlet.Filter

How filter chain invocation works?

本小妞迷上赌 提交于 2020-04-07 14:18:42
问题 I am trying to understand filter chaining.As defined in this question All filters are chained (in the order of their definition in web.xml). The chain.doFilter() is proceeding to the next element in the chain. The last element of the chain is the target resource/servlet. I am interested to know behind the scene in container that how container handles filter chaining.Can someone explain that how Filter chaining is handled inside container? 回答1: Each filter implements the javax.servlet.Filter

How filter chain invocation works?

和自甴很熟 提交于 2020-04-07 14:18:01
问题 I am trying to understand filter chaining.As defined in this question All filters are chained (in the order of their definition in web.xml). The chain.doFilter() is proceeding to the next element in the chain. The last element of the chain is the target resource/servlet. I am interested to know behind the scene in container that how container handles filter chaining.Can someone explain that how Filter chaining is handled inside container? 回答1: Each filter implements the javax.servlet.Filter

Tomcat filter generates duplicate localhost.log lines

纵饮孤独 提交于 2020-03-26 08:22:51
问题 This code, most of which I inherited, runs fine except System.out.println("Success") generates a lot (7-37, random) of identical lines in localhost.log instead of just one when it runs: Mar 1, 2011 8:49:47 AM org.apache.catalina.core.StandardWrapperValve invoke Success Mar 1, 2011 8:49:47 AM org.apache.catalina.core.StandardWrapperValve invoke Success Mar 1, 2011 8:49:47 AM org.apache.catalina.core.StandardWrapperValve invoke Success What's going on?? public class SpecialFilter implements

Interceptors Or Filters

回眸只為那壹抹淺笑 提交于 2020-03-18 05:53:26
问题 I am working on an Spring Application in which I want to do some security checks like MD5 checking of files, DB checking, Application version check etc. I have read about Interceptors and Filters but still a bit confuse about which one is good to use. Whatever documents I have read, it is specified that filters and interceptors both can be used for Logging and auditing so which one is good for this scenario. Also all this security checks (MD5 checking of files, DB checking, Application