jQuery in Action, 3rd edition
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes doubt in free mock exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "doubt in free mock exam" Watch "doubt in free mock exam" New topic

doubt in free mock exam

V Gala
Ranch Hand

Joined: Aug 06, 2007
Posts: 113

The above entry in the Deployment Descriptor will do what?

1 Route any request to your web application for a page or servlet that
cannot be found to not_found.html

2 Route any ServletExceptions with the code 404 thrown from your servlet to

3 Route any exception thrown in a servlet to not_found.html

4 Route any 404 requests to not_found.html

Answer given is 1

does anyone know explanation for answer
Ranch Hand

Joined: Oct 26, 2006
Posts: 58
I assumed in such a way

404 error mean file not found

so obviously for "a page or servlet that cannot be found" will display not_found.html
Francesco Bianchi
Ranch Hand

Joined: Jun 22, 2007
Posts: 62
I'm sorry, I don't really agree this is so obvious.

The resons I can give you are basically two:
  • For same very strange business rules, I could decide to force the error code of my response to be 404 even if a resource has been found
  • HTTP specs are out since a certain bunch of time...ok.. But what if in a future version the 404 code changes its meaning? I think there is a reason if it's saved somewhere as a public static final int... And that not only to attach it a label to clarify its meaning...

  • By the way.. I tried a Marcus mock 1 hour ago and did same mistake as V Gala

    SCJP 5 & 6, SCWCD 5, SCBCD 5
    Stevi Deter
    Ranch Hand

    Joined: Mar 22, 2008
    Posts: 265

    Here's a page with a good summary of what the web.xml <error-code /> tag does, which should explain why (1) is the correct answer.

    The summary is, exception handling takes precedence over error codes. If an exception is thrown and not handled, it's translated into a 500/503 error.

    I suspect the rest of the formulation of the question is to make sure you understand that error 404 is the "page not found" error.

    There will always be people who are ahead of the curve, and people who are behind the curve. But knowledge moves the curve. --Bill James
    Francesco Bianchi
    Ranch Hand

    Joined: Jun 22, 2007
    Posts: 62
    Thank you Stevi. You and B T R are right.
    I have been so stupid not to even read the word "ServletException" in answer (2). I apologize for my oversight.
    I agree. Here's the link: http://aspose.com/file-tools
    subject: doubt in free mock exam
    jQuery in Action, 3rd edition