I have written test Filter (javax.servlet.Filter) and started to debug. And I was surprised that one refresh of html page calls twice method doFilter().
Could anybody describe me why it happens ?
Thanks.
I have written test Filter (javax.servlet.Filter) and started to debug. And I was surprised
Share
Perhaps your filter was called also for static elements (images, etc.). Check your filter path declaration in
web.xml.One way to check what’s really happening is to use either Fiddler or Firebug. Or both.
Another strategy to use is printing value of
request.getRequestURL().toString()beforedoFilter(), so you can see what requests are being served. It’s difficult to pinpoint why are you seeing 2 requests because the cause might be hidden somewhere in your environment or configuration.