0. Server, servlet container, Web container
servlet container: An environment that can run a servlet is called a servlet container
Web container: An environment that is capable of running Web applications is called a Web container
Weblogic
Websphere
Tomcat
One, Tomcat installation
http://tomcat.apache.org/
There are decompression and installation version of Windows and Linux Edition, choose the version you want to download
TOMCAT5 Jdk4 or more
Tomcat6 Jdk5 or more
TOMCAT7 Jdk6 or more
Tomcat8 Jdk7 or more
You also need to configure the JAVA_HOME environment variable after decompression, point to the root directory of the JDK, specify which JDK to use when Tomcat starts
Booting Tomcat via Bin/startup.bat
Close Tomcat via Bin/shutdown.bat
The Tomcat installation configuration was successful by visiting http://localhost:8080 if you were able to see the homepage of Tomcat
The conf/server.xml can be used to specify the port that Tomcat listens to, we can listen to 80 port instead
Optional environment variable: catalina_home Specifies which location to start the Tomcat,tomcat at startup first check whether Catalina_home exists, if present, start the environment variable pointing to Tomcat, if not present, start the current Tomcat, No configuration is recommended.
Problems that may occur when you start Tomcat:
The installation location path must not have Chinese and white space, it may be 1:30, but I do not know when there may be an accident.
If the newspapers port is in error at startup, you can see which program is consuming the port through the Netstat-ano command, stop and then restart Tomcat.
Ii. the directory structure of Tomcat
Bin-A batch command to store Tomcat startup and shutdown
Conf--The directory where Tomcat's configuration file resides. Where Server.xml is the core configuration file for Tomcat.
Lib-the directory where Tomcat is required to run the jar package
Logs--The directory where the Tomcat log file resides
Temp-The directory where the Tomcat runtime generates temporary file storage. This directory Tomcat manages itself and does not need us to worry about.
WebApps--localhost managed directory, Web applications placed in this directory can be accessed through a browser to a localhost virtual host.
Work-Tomcat's working directory, which is stored in this directory as a working file generated during Tomcat's run.
!!! Third, Web applications
Directory structure for 1.web applications
Game
|
|--static Web Resources, JSP, placed in the Web application root directory of resources, through the browser can be directly accessed.
|
|--web-inf this directory when a special directory in the WEB application, this directory can not, but once there is a need to meet the requirements of the structure
The resources placed in this directory are protected and are not accessible directly through the browser.
|
|--classes directory of class files used to store dynamic Web resources
|--lib Dynamic resource dependent jar Package storage directory
|--web.xml the core profile of the current Web application, all configuration actions for the current Web application need to be done in this file.
* * Experiment: Configure the home page for your web app via the XML.
2. Deploy Web Apps to virtual hosts-virtual path mappings for Web apps.
Way One:
Configure <context path= "virtual path" docbase= "Real path to Web App" Under the <Host> tab of the virtual host you want to configure under <Engin> in Tomcat]/conf/server.xml />.
It is not particularly good to restart the server after each configuration.
If path is configured to be empty, the current web app becomes the default Web App.
Way two:
In [Tomcat]/conf/[engin]/[host]/xxxxxx.xml where the file name becomes the virtual path of the current web app, the file is written internally <context docbase= "The True path of the Web App"/> Specifies the true path of the Web App.
This configuration does not require a restart of the server to work.
The current web app becomes the default Web app as long as the file name is set to Root.xml.
Way three:
The virtual host can specify a directory that is managed by default when configured. As long as the web app is placed in that directory.
This configuration does not require a restart of the server to work.
As soon as you set the name of the Web App folder to root, the current web app becomes the default Web App.
!!! Four, virtual host
A virtual host can be configured under the <Engin> configuration <Host> tags in tomcat]/conf/server.xml. We also need to set the IP address and Domain name mapping to the NDS server to use the domain name access through the browser. However, general DNS can not be arbitrarily moved, we can use the Hosts file to simulate the function of DNS, complete the experiment.
There is a Defaulthost property on the <Engin> tab that allows you to configure the default virtual host for the current engine, and access the default virtual host when the user accesses IP to determine which virtual host is currently being accessed.
V. Other relevant
1. Fight a war bag
In the process of publishing, we usually package the Web app as a war package. The war package is placed in the directory managed by the virtual host, and the server knows the war packet and automatically extracts it to achieve the release of the application.
Way One: JAR-CVF Xxxx.war *
Method Two: Compress with compression tool to xxxx.zip modify suffix. zip is. War.
2. General Web. XML and General Context.xml
[Tomcat]/[conf]/web.xml This file is actually a generic Web. xml file. All Web applications that are currently configured in Tomcat can be thought of as "inherited" from this file.
[Tomcat]/[conf]/context.xml This file is actually a generic <Context> configuration, and all of the current web app's <Context> configurations in Tomcat are inherited from this <context >
Deployment of Tomcat