Solution to some simple questions from Tomcat servers, some simple problems often encounter (Z)

xiaoxiao2021-03-06  39

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

Default

Org.apache.catalina.servlets.defaultServlet

debug

0

Listings

True

1

Put it

Listings

True

Change to

Listings

false

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

404

/ notfilefound.jsp

java.lang.nullpointerException

/null.jsp

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)

30

4. Set the default welcome page (when you do not enter the file name, only enter the directory)

Index.jsp

Index.html

index.htm

---------------------------------------------------------------------------------------------------------------------------------------

The configured web.xml file is as follows:

---------------------------------------------------------------------------------------------------------------------------------------

Public "- // Sun microsystems, Inc.//dtd Web Application 2.3 // en"

"http://java.sun.com/dtd/web-app_2_3.dtd">

Tomcat Examples

Tomcat Example Servlets and JSP Pages.

Session timeout setting

Set the session expiration time, unit is minutes;

->

10

Index.jsp

Index.html

index.htm

404

/ notfilefound.jsp

500

/common/500.jsp

java.lang.nullpointerException

/null.jsp

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 /

404 filenotfound.jsp

->

转载请注明原文地址:https://www.9cbs.com/read-68813.html

New Post(0)