In-depth understanding of the Java Tomcat virtual directory

Source: Internet
Author: User

We know that the content of the Web site (including Web pages, images, audio files, etc.) is generally stored in the app's directory. But as the content of the site continues to enrich, users need to organize different levels of content into sub-directories of the site. We usually do this by creating a new subdirectory in the home directory and placing the relevant content in the corresponding directory. In addition, there is another way to create a virtual directory. A virtual directory can be any path that has permissions on the disk (setting the virtual path to ReadOnly is absolutely not possible), or it can be a directory for other computers on the network.

I QQ group also has a lot of technical documents, I hope to provide you with some help (non-technical not to add).

QQ Group: 281442983 (click the link to join the group: http://jq.qq.com/?_wv=1027&k=29LoD19)

In contrast, creating subdirectories is more secure and efficient. But why do you have a virtual directory? This is because the virtual directory solves the challenge of Web files that must be placed in the Web root directory. On the one hand, this greatly increases the storage space of the Web project. On the other hand, it also provides a guarantee for sharing the same document for many different projects.     For example, when more than one site needs to access the same file, we simply point the virtual path to the address of the changed file, which avoids the problem of multiple copies of the same file. Under the TOMCAT7 version, configure the virtual path to modify the following two files: 1.server.xml open the/conf/server.xml file under the Tomcat directory and add the following Red section before host.
Path: Project name + file path, when accessing files in the path directory, actually access files under the Docbase directory. DocBase: The true path of the file. Note that if there is a file long pass, the uploaded file path is set to Docbase instead of path. 2. Web. XML opens the/conf/web.xml in the Tomcat directory and sets the listings property of the red section below to True.
<servlet>    &NBSP ;   <servlet-name>default</servlet-name>        <servlet-class> org.apache.catalina.servlets.defaultservlet</servlet-class>        <init-param>             <param-name>debug</param-name>          &N Bsp <param-value>0</param-value>        </init-param>        <init-param>            <param-name>listings</param-name>            <param-value>true</param-value>        </ init-param>        <load-on-startup>1</load-on-startup>    </servlet
Admittedly, the use of virtual directories has brought great convenience to our development and deployment, but since the configuration of the virtual directory must be set to true for the listings property, all files under that directory are exposed to the user, which poses some risks to the use of the system. Therefore, choose to use the virtual directory must be cautious. I QQ group also has a lot of technical documents, I hope to provide you with some help (non-technical not to add).

QQ Group: 281442983 (click the link to join the group: http://jq.qq.com/?_wv=1027&k=29LoD19)

In-depth understanding of the Java Tomcat virtual directory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.