• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javaranch mock exam

 
jyothi sanka
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • 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?

I think this one is the correct answer:
Route any ServletExceptions with the code 404 thrown from your servlet to
not_found.html

but they gave this one is the correct answer:
Route any request to your web application for a page or servlet that
cannot be found to not_found.html

please explain me.
thanks
 
Rohit Bhagwat
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Status code set with sendError() method will only be responsible for invoking those files from location tag.
If ServletException is thrown then page specified in location tag is not invoked because u specified error-code. So it will not map to that file

I hope I am clear
Regards
Rohit.
 
Colin Fletcher
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have answered your own question.

When the applications throws a Servlet Exception it does not have an error code of 404.

If you type http://www.google.com/somepagethatdoesnotexist.html, the server will try to load the page. When the server is unable to find the page, it sends an error code of 404 "not found" back to the client.

You may want to consider reading some of the HTTP spec to help you understand the error codes.
-C
 
jyothi sanka
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now I got it.
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic