• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Mistake in Head First Servlets & JSP

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm currently preparing for my SCWCD exam with a copy of OReilly - Head First Servlets And JSP - 2nd Edition (Mar 2008).

I'm hoping someone can check up what I THINK is a mistake on page 712:

The filter mappings which use <servlet-name> have urls in them. Shouldn't these be names of servlets??

I can't see it mentioned in the books online errata.

Can you also have multiple <url-patterns> or <servlet-names> as of Servlet Spec 2.5. Is this true also for the SCWCD 083 exam?

Thanks for your Help
Eurig
 
Author
Posts: 836
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For those of us who don't own the book it would be handy if you could supply a slightly more elaborated description of the problem.

However, <servlet-name> elements in <servlet-mapping> and <filter-mapping> should always contain a contents of a corresponding <servlet-name> in a <servlet>. So from what you say alone, I believe it is indeed a mistake.

Can you also have multiple <url-patterns> or <servlet-names> as of Servlet Spec 2.5. Is this true also for the SCWCD 083 exam?

You are certainly correct that Servlet 2.5 spec allows multiple <url-pattern>s and <servlet-name>s in a single <filter-mapping>, and that only one of these may have been used in v2.4 and earlier. An educated guess would tell me that only one element is ever going to appear in a <filter-mapping> in the exam, so you won't be asked peculiarities about how many elements are allowed - so it shouldn't be a problem as far as the exam is concerned. A more typical question would be to ask you to structure a <filter-mapping> tag via drag-and-drop, and there will only be one correct answer (hence can only be either a <url-pattern> or a <servlet-name> to be used).

Hope that helps.
 
Ericson James
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It helps a lot Charles. Thanks.

And as you mentioned. For those of you who don't own the book. It goes a bit like this:



Write down the sequence in which the filters will be executed for each request path:

/Recipes/HopsReport.do
/Recipes/HopsList.do
/Recipes/Modify/ModRecipes.do
/HopsList.do
/Recipes/Add/AddRecipes.do

[ August 23, 2008: Message edited by: Eurig Jones ]
 
Charles Lyons
Author
Posts: 836
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It could be valid - if the servlets in question have a <servlet-name> with the URL-like value; for example:I imagine that would be valid under the Servlet spec., but is unlikely to ever be used even so...
 
Ericson James
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good point.

Then I guess it's not an error but just a very evil question which makes you think its actualy a mistake and not just a trick question!
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IMHO it probably is an unintentional mistake on behalf of the author of the book.

However it's *VERY* good practice for the actual exam as it encourages you to read the question slowly and carefully rather than skim it and make assumptions.

My biggest failing when I took the exam was skim a question, think I knew what knowledge it was getting me to demonstrate, and plump for an answer. I am sure I would have got a higher pass score if it'd actually slowed down, read, and re-read!

Rufus.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
to Eurig Jones:

I thought there is a mistake too, but then, just above the excercise I saw this text:

Assume Filter1 through Filter5 have been properly declared, and that the servlet names are the same as their mappings.

So remember to re-read the questions on the exam and good luck!
 
Misho Chigrichenko
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In fact I forgot to share something that I see as a mistake in the book. Of course maybe I am wrong, too...

Look at the code of the that overrides the and methods of . Sorry, I won't paste it here, because its lengthy, so only the people who have the book could understand me...

1) As I am aware, should not be called after and vice-versa. If this is done, the caller should get an ...

2) The IF in method that checks whether to throw an is: . But if you have already called , you have set the member var to point to exactly pw which is an instance of ! So this way it is possible to call getOutputStream() after you've called . Instead you get the exception if you call twice!

3) I think it would be right to have in !

Please, tell me if I am wrong...
 
Misho Chigrichenko
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for misusing in such a way... I am a greenhorn, see
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're right.

Check the errata of The Book. It's mentioned there.
[ September 10, 2008: Message edited by: Jan Sterk ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic