When a directory is requested from Tomcat, it will look for a default page
to display. This page is usually named index.jsp
, but it can
be changed to any other name by using the welcome-file-list
tag. Several welcome files can be defined in the list.
<welcome-file-list> <welcome-file>myFile.jsp</welcome-file> <welcome-file>otherFile.jsp</welcome-file> </welcome-file-list>
Tomcat uses its own default messages for 404 errors and 500 errors. A page
of your own choice can be created and displayed instead of the default page
by using the error-page
tag. Create a separate
error-page
tag for each error to be redefined.
<error-page> <error-code>500</error-code> <location>/myDir/myFile.html</location> </error-page>
Tomcat does not distinguish amongst all the 400 errors, they are all treated as a 404 error. This means that if there is a file that exists, but has the wrong permissions, then Tomcat will catch that as a 404 error, not a 403 error.
If you are using Internet Explorer, then you need to go to the Advanced Internet Options and uncheck Show Friendly HTTP Error Messages. You may also need to be sure that you error file is larger than a minimum size. I am unable to duplicate this problem, but students report that the problem exists. If your error file is too small, you may still see the friendly error message.
If you have already displayed a default error message and then change to a custom error message, be sure that you clear the cache so that the old error message does not display.
For more info on the web.xml file you can view the DTD for it: http://java.sun.com/dtd/web-app_2_3.dtd
This is the order of all elements in the web.xml file. The only required element is web-app. If an element is followed by a ?, then it can only appear once. If the element is followed by a *, then it can appear multiple times, but all grouped together.
web-app ( icon?, display-name?, description?, distributable?, context-param*, filter*, filter-mapping*, listener*, servlet*, servlet-mapping*, session-config?, mime-mapping*, welcome-file-list?, error-page*, taglib*, resource-env-ref*, resource-ref*, security-constraint*, login-config?, security-role*, env-entry*, ejb-ref*, ejb-local-ref* )