This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Zero to AI - A non-technical, hype-free guide to prospering in the AI era and have Nicolò Valigi and Gianluca Mauro on-line!
See this thread for details.
Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Who is First Filter or Servlet

 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we will define both Filter and Servlet mapping in web.xml with same URL pattern.
If we call the URL which one is called First.
Servlet or Filter.

Thanx
sanjay
 
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Filters. Mapping purpose is differnt for filter and servlets.
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To confirm, it is the chain.doFilter(request, response) in the Filter above, that calls the servlet with the same url-mapping? Right?

What I am little confused on is ... if filters have matching url-pattern but do not have a servlet-name mapped and there is no servlet with a matching url-mapping, then do filters run on their own with no servlet being called at all.
 
Sanjay pts
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
sumit

Think ,that whats the use of filter and servlet .Then the dought will be claer that FILTER will always be called first b'se its Intercepting request and response .

Thanx
Sanjay
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Your Quote

What I am little confused on is ... if filters have matching url-pattern but do not have a servlet-name mapped and there is no servlet with a matching url-mapping, then do filters run on their own with no servlet being called at all.



I think the container first find the matching Servlet. If the matching servlet is found then only it execute the filters that matched the given URL before executing the Servlet. The Filters can terminate the processing in between, if required. If no Servlet mapping is found, no filter will run even though the filters have matching URL.

Thanks
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Also, The code after doFilter(..) method of FilterChain method executed after the Servlet.

Thanks
 
A "dutch baby" is not a baby. But this tiny ad is baby sized:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic