In question 65 on p824 of HFJS (which I can't repeat here due to time constraints) they mark answer C as among correct, which basically says that the doFilter() method of a filter you implement MUST include a call to chain.doFilter(). They even say exactly that in the notes, I quote: "if nothing else, doFilter() must invoke chain.doFilter()".
There is no mention in the question of any requirement that the next filter or even the servlet be processed. Only that "a programmer is creating a Java EE web application". But even in that case there it is not a MUST to call chain.doFilter(). A "Java EE web application" could certainly implement a filter that never calls chain.doFilter(). As a matter of fact, from what I understand of Struts 2, they have filters that never call chain.doFilter(). Instead they call their own framework classes (could be wrong though, haven't actually worked with it).
Ok, I agree I'm just whining here, and I have no actual question. But I just need to share with someone that it concerns me that the people who wrote the test I am about to take have used such inaccurate language in their sample test questions.
I quote: "if nothing else, doFilter() must invoke chain.doFilter()".
That's a wrong statement. There are plenty of uses of Filters which deliberately do not call the next in the chain, for example authorisation checkers which deny access. You mentioned before you have a copy of my book, so Figure 7.3 on p.160 and the skeleton code example on p.164 both emphasise why and when not to pass to the next filter.
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / AmazonAmazon UK )
In question 65 on p824 of HFJS (which I can't repeat here due to time constraints
I don't have a copy of the book with me, it's possible that you found an error, but in general it's WAY better to post the entire mock question, wherever you got it from, when you raise a doubt. Again, while you might have found an error, in many cases candidates miss a subtle aspect of the question which is lost if the entire question isn't posted. In other words, maybe you got the context correct, and maybe you didn't.
Please post the entire question when you've got the time!
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
posted 11 years ago
(Wow, I got the author to reply! How cool is that?)
Hi Bert. Thanks for jumping in.
I definitely could have missed a subtle aspect. That's why I post asking for opinions.
And I would LOVE to post the whole thing! Um, is it from somewhere cut/pastable? It's a biggy. If I mistype something I could squelch the subtlety that maybe caused my misunderstanding in the first place (or introduce a NEW subtlety that wasn't even supposed to be there!)
The knights of nee want a shrubbery. And a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!