When you configure Tomcat, I want to ban access to the list of directory. The result found a good article through Google's search. In addition to what I want, there are some other useful things.
Source:
Your blog.com (Yourblog.org)
When doing JSP, some simple questions about Tomcat servers are optimized and often encountered:
1. How to disable access to the directory list:
Modify one attribute value in Tomcat X.x / conf / web.xml, that is, change True to False
Find the following code in Web.xml
Org.apache.catalina.servlets.defaultServlet
servlet-class>
init-param>
init-param>
servlet>
Put it
init-param>
Change to
init-param>
2. If a file resource is not found, the server will report 404 errors,
If a JSP file is executed, NullPointexception is generated
Will display some do not want to abnormally prompt code,
In order to let users see more more friendly pages
Set as follows in Web-INF / Web.xml of our own virtual directory
Error-Page>
Error-Page>
Similarly, you can also set the page that should be displayed when throwing other exceptions!
In addition, in the JSP page, add such a sentence.
<% @ page isrrorpage = "true" errorpage = "error.jsp"%>
You can also capture this anomalies of NullPointersException, and turn to Error.jsp at this time.
3. Set the timeout time of the session (unit: minutes)
session-config>
4. Set the default welcome page (when you do not enter the file name, only enter the directory)
welcome-file-list>
---------------------------------------------------------------------------------------------------------------------------------------
The configured web.xml file is as follows:
---------------------------------------------------------------------------------------------------------------------------------------
Xml Version = "1.0" encoding = "ISO-8859-1"?>
Public "- // Sun microsystems, Inc.//dtd Web Application 2.3 // en"
"http://java.sun.com/dtd/web-app_2_3.dtd">
Tomcat Example Servlets and JSP Pages.
description>
Session timeout setting
Set the session expiration time, unit is minutes;
->
session-config>
welcome-file-list>
Error-Page>
Error-Page>
If a file resource is not found, the server wants to report 404 errors, and notfilefound.jsp is called according to the above configuration.
If a JSP file executed is generated, null.jsp is called
->
The following is wrong, less one /
Error-Page>
->
web-app>