Web Application Development (2)

Source: Internet
Author: User

 

Web Application Development (2)

<A host represents a Web site>

1. root directory of the virtual directory

By default, webapps/root specifies that this directory is the root directory of the web site.

Specify a file system directory as the root directory of the web site. in XML, add

2. subdirectory of the virtual directory

(1) on the server. add <context Path = "/book" docbase = "E: \ test" DEBUG = "0"/> to the

(2) Each subdirectory in the webapps directory is mapped to a virtual subdirectory. The virtual subdirectory name is the same as the file system subdirectory name.

(3) create a war package and configure it in the server. xml file.

<Context Path = "/student" docbase = "D: \ myweb. War"/> the virtual subdirectory name is the same as the path attribute value.

Debug can be left empty. Its value indicates the size.

(4) pack the war package into a webapps package. The virtual subdirectory name is the same as the war package name.

Package: e: -- dir --- CD myweb --- dir --- jar CVF myweb. War. [. indicates all files in the current directory]

 

Deployment descriptor and default page

Tomcat/CONF/web.html // deployment descriptor set in the container, which is effective for all web applications deployed in the container

WEB-INF/web under each web application virtual subdirectory. XML // set your own special configuration. If the configuration in it has the same configuration as the deployment descriptor set in the container, it will overwrite the configuration set in the container.

 

Settings on the hosts page

When the search name is incomplete and you press enter directly, the search will be performed in the following order. If none of them are found, the Error 404 is reported and is not found (F: \ Tomcat \ conf \ WEB. XML)

<Welcome-file-List>

<Welcome-File> index.html </welcome-File>

<Welcome-File> index.htm </welcome-File>

<Welcome-File> index. jsp </welcome-File>

</Welcome-file-List>

 

Configure a VM

Web Resource Access by browsers

URL ---- format: http: // ip address (or host name): Port Number/directory name/Webpage file name

 

Virtual Host and implementation principles

Objective: To create multiple web sites on a computer and set different home directories and directories for each web site. Each web site is assigned to different companies or departments as its own independent websites.

Principle:

Each web site on the Web server must have different identification information.

The connection and request information sent by the Web Browser contains the website ID information.

Web site ID information:

IP address, port number, Host Name

 

Host Name-based VM

Two Web Sites

1. Host Name: Site1 http: // Site1: 8080/index.html

2. Host Name: Site2 http: // Site2: 8080/index.html

Http: // host name: 8080/index.html

 

VM settings:

Conf/server. xml

<Host name = "Site1" appbase = "E: \ virtualhost1">

<Context Path = "docbase =". "/> <! _ Set to root directory __>

</Host>

<Host name = "Site2" appbase = "E: \ virtualhost2">

<Context Path = "docbase =". "/>

</Host>

When no virtual host is set for the web site to be accessed, the default site is accessed.

 

Port-based VM

Website 8080

Website 8081

Http: // localhost: 8080/index.html

Http: // localhost: 8081/index.html

 

<Service name = "tomcat_second">

<Connector Port = "8081" protocol = "HTTP/1.1"

Connectiontimeout = "20000"

Redirectport = "8443"/> // Connector

<Engine name = "Catalina" defaulthost = "localhost"> // Engine

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.