1- Filter chain order is affected by whether filter mappings are declared via <url-pattern> or via <servlet-name>. TRUE
I need clarification on this. Any input?
2- Filter supports an initialization mechanism that includes an init() method that is guaranteed to be called before the filter is used to handle requests.FALSE
A agree with what you say regarding Statement #1. My doubt is whether these two things match (what you say and what is given there). Does that mean something else.
I am still doubtful regarding statement #2. It is given false in the book. If it is really false, I guess the reason is Filter does not handle the client request. Not sure.
->Instantiate an instance of each event listener identified by a <listener> element in the deployment descriptor.
->For instantiated listener instances that implement ServletContextListener, call the contextInitialized() method.
->Instantiate an instance of each filter identified by a <filter> element in the deployment descriptor and call each filter instance�s init() method.
->Instantiate an instance of each servlet identified by a <servlet> element that includes a <load-on-startup> element in the order defined by the load-onstartup element values, and call each servlet instance�s init() method.
If you consider the statements from specification the question is correct.But according to the subject or from head first book.we can sure that the answer is false.I thought that question as specific.I did not think that question as a general one.
If the same question appeared in exam i would go for false .Because there is no init() method in filer life cycle.
I dont have the details of the question but looking at only the stmt and assuming that its referring to the init() method with the right argument the stmt looks true.
if this is the statement -------------------------------------------------------------------------- Filter supports an initialization mechanism that includes an init(FilterConfig config) method that is guaranteed to be called before the filter is used to handle requests -------------------------------------------------------------------------
Then the answer is true
Because according to the specification 2.4 .The container has to create an instance of the filter class and must call the init(FilterConfig config) at deployment time or just before processing the first request to the particular servlet or jsp.
HFJS errata says that option to be correct. In specification init() method is said to be called although there is no direct mention of init(), instead init(FilterConfig) exits.
I wonder if this sort of confusing questions we encounter in the real exam, it would be very difficult.
This question has been debated quite often at the ranch. I sometimes say that there is no init() method. But the question seems to be asked in an awkward manner, and the errata of HFSJ has been updated accordingly. Be sure that you won't get such an ambiguous question at the exam.
Post by:autobot
Die Fledermaus does not fear such a tiny ad:
a bit of art, as a gift, the permaculture playing cards