Java EE 7 Application Developer — Question 11
How do you specify a default error page in your web.xml file?
Answer options
- A. <on-error> <location>/general-error.html<location> </on-error>
- B. <error-page> <error-code>*</error-code> <location>/general-error.html</location> </error-page>
- C. <on-error> <error-code>*</error-code> <location>/general-error.html</location> </on-error>
- D. <error-page> <location>/general-error.html</location> </error-page>
Correct answer: B
Explanation
The correct answer is B because it properly uses the <error-page> tag along with <error-code>*</error-code> to specify that the page should be displayed for all error codes. Options A and C incorrectly use <on-error>, which is not a valid tag for defining error pages in web.xml. Option D lacks the <error-code> tag, making it insufficient for specifying a default error page.