JSP/servlet Study Notes (3)

Source: Internet
Author: User

Tomcat directory structure

 

Note: The lib directory stores jar files, where:

Server/lib: jar files in the directory can only be accessed by the Tomcat server

Shared/lib: accessible to all web applications

Common/lib: accessible to Tomcat servers and all Web Applications

In addition, the jar stored in lib under the WEB-INF directory in each web application can be accessed by Tomcat and all web applications.

 

Create and publish Web Applications

Each component has a fixed storage directory in the Web application. the Web application configuration information is stored on the web. in XML, some components must be published on the web. add the corresponding configuration information in XML.

 

An application has WEB-INF/classes and WEB-INF/lib, both can store Java class files. during the running process, the Tomcat Class Loader Xi 'an loads classes under the classes directory and then the class under Lib. Therefore, if there are classes with the same name under the two directories, the class under the classes directory has priority.

 

Web. xml file

<? XML version = "1.0" encoding = "ISO-8859-1"?>

<! Doctype web-app public…>

<Web-app>

</Web-app>

 

The first line defines the XML version and character encoding.

Line 2 document types

Next, a <web-app> element is declared. All configuration elements about the web application will be added to this element.

 

Add the <context> element to server. xml

The <context> element is server. the most frequently used element in XML, which represents a single web application running on

Context attributes:

Path: Specifies the URL entry to access the Web application.

Docbase: Specifies the file path of the Web application. If it is a relative path, it is the value of the appbase attribute relative to the host.

Reloadable: if it is true, the Tomcat server will monitor changes to the class files under the WEB-INF/classes and WEB-INF/lib directories while running, if there is a class file update, the server automatically reloads the web application.

Tip: It is helpful for debugging to set reloadable to true in the development stage. however, this function will increase the load on the server. Therefore, we recommend that you set this attribute to false during the web application product release phase.

 

Related Article

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.