Tomcat directory Structure and purpose

Source: Internet
Author: User

Directory Structure and purpose

Directory

Use

Bin

Contains startup/shutdown scripts

Conf

Contains different configuration files, including Server.xml (Tomcat's primary profile) and a file that sets default values for different tomcat-configured web apps. xml

Doc

Contains a variety of tomcat documents

Lib

Contains the jar files used by Tomcat. UNIX platform any files in this directory are added to Tomcat's classpath

Logs

Log files that hold Tomcat

/server

Consists of 3 subdirectories: Classes, lib, and WebApps

Src

Servletapi source files. Don't be happy, these are just some empty interfaces and abstract classes that must be implemented within a Servlet container

WebApp

Contains examples of Web projects, where Web folders are placed in this directory by default when publishing Web Apps

Work

Tomcat automatically generates temporary files for the Tomcat runtime, such as a compiled JSP file. Delete this directory when Tomcat is running. The JSP page will not run. [JSP-generated Sevlet in this directory]

Classes

You can create this directory to add some additional classes to the classpath. Any class that you add to this directory can find itself in the Tomcat classpath.

Common/bin

There are JAR files that the Tomcat server and all Web applications can access

Server/bin

There are various JAR files required to run the Tomcat server .

Share/bin

There are JAR files that all Web applications can access ( cannot be Tomcat access )

/server/webapps

Store Tomcat two self-hosted web App Admin app and manager app


As you can see from table 2, jars can be placed under the Server/bin,share/bin,common/bin directory, the difference being:

The jar files in the Server/bin directory can only be accessed by the Tomcat server.

In Share/bin, the jar file under the directory can be accessed by all Web applications, but not by the Tomcat server.

Jar files in the Common/bin directory can be accessed by the Tomcat Server and all Web applications .

In addition, for the following introduction Javaweb application, in it's Web-inf directory, you can also create Lib subdirectory, in Lib Sub-directories can store a variety of JAR files, these JAR file can only be used by the current WEB application is accessed. The Javaweb app consists of a set of static HTML pages, Servlets, JSPs, and other related classes. Each of these components has a fixed directory in the Web application. The configuration information for the Web application is stored in the. xml file. When you publish certain components, such as Servlets, you must add the appropriate configuration information in the Web. xml file.

To publish the Web application on the Tomcat application server, you should create the directory structure of the Web app under the <catalina_home>/webapps directory.
Directory structure for Web Apps

Directory

Description

/helloapp

Web application root directory, all JSP and HTML files are stored in this directory

/helloapp/web-inf

Publish description file hosting Web App. xml

/helloapp/web-inf/classes

Store various class files, and the servlet class files are also placed in this directory

/helloapp/web-inf/lib

Store the various jar files required for your web app. For example, in this directory, you can store the JDBC driver jar file.

Note: In the classes and Lib subdirectories, you can store Java class files. During the run, the Tomcat class loader first loads the classes under the classes directory and then loads the lib. Tomcat's configuration file

The configuration of Tomcat is based on two configuration files:

1.server.xml-tomcat Global configuration file 2.web.xml-configuring different relational environments in Tomcat

Server.xml

Server.xml is the master configuration file for Tomcat. Complete two goals:

1 provides the initial configuration of the Tomcat component.

2 illustrates the structure of Tomcat, meaning that Tomcat completes the start and build itself by instantiating the component, as specified in the Server.xml

Important elements of the Server.xml species:

Elements and their descriptions

Server

The most important element in the Server.xml file. Server defines a tomcat server. Generally you don't have to worry about him too much. The server element can contain logger and contextmanager element types

Logger

This element defines a logger object, each logger has a name to identify, and a record logger the output and redundancy level (describing this log level) and the path that contains the log file. There is usually a servlet logger (ServletContext.log (), JSP and Tomcat runtime logger.

ContextManager

ContextManager describes a set of contextinterceptor,requestinterceptor, context, and their connectors configuration and structure. ContextManager has several features that accompany the offer:

1. Debug level used to record debug information

2.webapps/,conf/,logs/and the basic location of all defined environments. Used to enable Tomcat to start in other directories outside of Tomcat_home.

3. Name of the working directory

Contextinterceptor&requestinterceptor

These listeners (interceptors) listen for events that occur specifically in ContextManager. For example, Contextinterceptor listens for Tomcat startup and termination events, Requestinterceptor monitors the different stages in which a user request needs to be passed during its service. Tomcat administrators don't need to know much about listeners, and developers should know how to implement a "global" Operation in Tomcat ( such as security and each request log)

Connector

Connector represents a join to the user, either through a Web server or directly to the user's browser (in a separate configuration). Connector is responsible for managing Tomcat's worker threads and read/write requests/responses to ports that are connected to different users. The connector configuration contains the following information:

1. Handle Class

2. TCP/IP port for handle listening

3. Handle the TCP/IP backlog for the server port.

Context

Each context provides a subordinate directory that points you to the tomcat where you placed your Web project. Each context contains the following configurations:

The path of 1.Context placement, which can be the path associated with the ContextManager home directory.

2. Record debug level of debug information

3. Can be overloaded with flags. When you develop a servlet, you overload the changed servlet, which is a handy feature that you can debug or test new code with Tomcat without stopping or restarting Tomcat. To turn on overloading, Set the reloadable to True. This takes time but can detect the changes that occur; the more important thing is that class mount triggers may throw some errors when a load class object loads a new servlet. To avoid these problems, you can set the overloads to false, which will stop the overloaded functionality.

Xml

Tomcat allows users to define the default value of Web. XML for all relational environments by placing the default Web. XML in the Conf directory. When building a new relational environment, Tomcat uses the default Web. xml file as the basic settings and application-specific Web. XML ( Web-inf/web.xml files that are placed in the application project) to override these default values.

Source: http://blog.sina.com.cn/s/blog_5677bc5401000c52.html

Tomcat directory Structure and purpose

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.