aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Help needed on Filters - page 700/Qtn 1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Help needed on Filters - page 700/Qtn 1" Watch "Help needed on Filters - page 700/Qtn 1" New topic
Author

Help needed on Filters - page 700/Qtn 1

Mani Jagathesan
Ranch Hand

Joined: Sep 19, 2005
Posts: 33
I need some clarification with the answers for this question.

c. The doFilter() can be called by the container and also the preceding filter. Is this what is meant my inline method?

Hence, it is not a container call back method only.

d. A filter can also be invoked by the preceding filter, in that case won't this option be incorrect?

Or, does "invoke" mean the very first filter to be invoked?

Thanks & regards,

Mani
Frederic Esnault
Ranch Hand

Joined: Feb 13, 2006
Posts: 284
I didn't understand your question. However here is the invocation mechanism :

Filters are used as a stack. At webapp deploy time, Container creates a list of Filters to be applied to request (check out rules, url-pattern before servlet-name...)
When one of theses "filtered requests" is requested, then the Filter, if applicable, is called (doFilter). After this, Filter has the end and may call the next filter (or servlet if it's the last filter in list) using its FilterChain doFilter() method. If next component is a Filter, calling FilterChain doFilter mehtod calls the next Filter's doFilter method.

Does this help?


SCJP 5 - SCWCD 1.4 - SCBCD 1.3 - Certification study documents/resources: http://esnault.frederic.free.fr/certification
Mani Jagathesan
Ranch Hand

Joined: Sep 19, 2005
Posts: 33
A filter can be invoked from the previous filter or by the container (if it matches the url patter/servlet etc,.).

In that case, option D would not be a correct answer for this question. Am I correct?

Option D says - The only way a filter can be invoked is through a declaration in DD.

Thanks for your help.
Frederic Esnault
Ranch Hand

Joined: Feb 13, 2006
Posts: 284
No option D is correct. The spirit of this option, if it was false, is to say that there is another way (programmatically) to configure a Filter to be invoked when a servlet is requested. Which is not possible.

The FilterChain doFilter() method does not invoke a Filter, it just gives it the hand, until execution completes and hand comes back to the calling Filter ( remember the stack view of filters).

When you configure Filters in DD, Container builds a list of Filters it gives to a FilterChain object. The FilterChain object, when used to call next Filter, refers to Container list to "invoke" next one, which has been configured in DD.

I'm not sure of being really clear. The main point and "spirit" there is that Filters are loaded, instantiated, initialized and INVOKED only thanks to declaration in the DD. There is NO other way to configure/load/initialize or invoke a Filter.
The whole Filter mechanism is Container based (from the construction of the Filter list to the Filter chaining mechanism), and configured by DD declarations.

With this view in mind, option D is definitely correct.

Inline method means this method can be called by your code. A container callback method, the opposite, is a method that may only be called by the container, as an answer to an event.


Option A is incorrect, this is obvious.
Option C is not correct as it may be called by you, via the FilterChain.
And option E is not correct because filter chain is built by the container, at deploytime, and this is the only way to do so.


Was i clear?
Mani Jagathesan
Ranch Hand

Joined: Sep 19, 2005
Posts: 33
Yes, that was very helpful. Thanks very much.

Mani
Mani Jagathesan
Ranch Hand

Joined: Sep 19, 2005
Posts: 33
I tried a mock (one of the 'difficult') tests from J2EECertificate.com and the result was not encouraging. I am going through your notes (links in your signature) and they are very helpful, to the point.

Any tips would be very helpful.

Thanks,

Mani
Frederic Esnault
Ranch Hand

Joined: Feb 13, 2006
Posts: 284
Sorry i didn't get your point. You want tips about what? About my notes or about questions in the difficult exam you took? I don't get it.

If you're afraid your level is too low, then try exams from whizlabs SCWCD simulator, or from Enthuware JWeb+, they have free mock i think. Or, but it should be good to keep this one for when you feel ready, take the HFSJ exam (knowing about the theorical "20% rule" (which worked for many of us)).

Does this help? If not, please make your question clearer and i'll be glad to help.
Mani Jagathesan
Ranch Hand

Joined: Sep 19, 2005
Posts: 33
Frederic,

Sorry I wasn't clear. I meant to ask for any tips on doing well in the real exam.

Your notes are very helpful. I plan to give the mock exams from J2EECertificate.com, JDiscuss.com and the HFSJ mock exam. I will let you know if I need more help.

Thanks again.
Frederic Esnault
Ranch Hand

Joined: Feb 13, 2006
Posts: 284
If you read the HFSJ, used my notes , read the specs (mostly servlet specs, plus a JSP an JSTL read through) you should make sure you have a good understanding of how thing works, from a schematic overview to concepts. With a clear understanding, most of the questions are obvious, that's what you should work on.

And take your time, don't rush to the exam if you don't feel confident.

Good luck to you !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help needed on Filters - page 700/Qtn 1