wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Filters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Filters" Watch "Filters" New topic
Author

Filters

MaheshS Kumbhar
Ranch Hand

Joined: Sep 24, 2009
Posts: 188
I read in "Head First Servlets and JSP" that if container cant find the right resource for the request, the filter is never invoked. Here by "right resource" do we mean servlet/jsp or even welcome file?


I am slow but sure
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1635
    
  23

Hi MaheshS,

A filter always works on either a:
  • Dynamic web-resource, i.e. Servlet, matched by a servlet name
  • Static web-resource matched by an URL-pattern

  • If the filter-mapping doesn't match a servlet name or a static web-resource ( that means the url-pattern doesn't make a match), then the filter is never invoked
    If you have a default mapping '/' in the <url-pattern> of a <filter-mapping>, then the filter is never invoked ('/' is only used for the default servlet)

    But if you have a mapping of '/*' (meaning all the requests) in the <url-pattern> of a <filter-mapping>, the filter is always invoked, but it can still fail with a "resource unavailable".

    Regards,
    Frits
    MaheshS Kumbhar
    Ranch Hand

    Joined: Sep 24, 2009
    Posts: 188
    Thanks Frits
    But I didnt get the term default servlet.
    ('/' is only used for the default servlet).
    Frits Walraven
    Creator of Enthuware JWS+ V6
    Bartender

    Joined: Apr 07, 2010
    Posts: 1635
        
      23

    have a look at the specification Servlet 2.4, section SRV.11.1 (and maybe SRV.9.10 about welcome files)

    Regards,
    Frits
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Filters
     
    Similar Threads
    EJB3- resource injection in JSP
    SSL Info Required
    RequestDispatcher in JSP
    Internationlization JSP Labels
    Doubt in Specs