Forums Register Login

javaranch mock exam

+Pie Number of slices to send: Send
<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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
Now I got it.
Thanks
CAUTION! Do not touch the blades on your neck propeller while they are active. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 628 times.
Similar Threads
Error code 404
Handle all error codes other than one
response.setStatus
Mock Question: Why Only 1 Correct Answer when...
doubt in free mock exam
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 00:34:55.