Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

doubt in free mock exam

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<error-page>
<error-code>404</error-code>
<location>/not_found.html</location>
</error-page>

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
not_found.html


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
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
     
    Ranch Hand
    Posts: 265
    Hibernate Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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.
     
    Francesco Bianchi
    Ranch Hand
    Posts: 62
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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.
     
    WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
    Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    reply
      Bookmark Topic Watch Topic
    • New Topic