• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what happens when Filter and Servlet mapped to same url-pattern

 
Srinivasan thoyyeti
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

BE the container (scope = this post alone )
I have already tested this scenario.
Just treat this like HF SCWCD book exercise.
very simple and useful. know who rules over whom !!!

CASE #1

What happens if filter and servlet both mapped to same url-pattern like this?




we should not use such mappings.
This is only for observation.
================================================
CASE #2

who wins against filter and security constraint with same mappings.
(Assume that Authentication information is configured)
Whether BASIC authentication dialog shown (or)
Filter processed ?

 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Case #1, there is no mapping to the filter to resource.
<filter-mapping>
<filter-name>...</filter-name>
<servlet-name>...</servlet-name>
</filter-mapping>


If I understood the factor you mentioned in your observation.
Filter is always instantiated first.
Filter runs in the sequence they are declared in the DD (I mean
according to <url-pattern> .
Finally in the filter chain servlet is forwarded as given in <servlet-name>.

Correct me if I go wrong!

Thanks,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic