How to replace the Tomcat default home page

Source: Internet
Author: User
Tags documentation


Preface:

After the Tomcat is installed, we enter the URL (or IP) and visit Tomcat, which appears as the Tomcat welcome interface, as follows:



Then how can you enter the address to access our own published default welcome interface. The method is as follows:


First, open the Tomcat/conf/server.xml file and locate the following code snippet:

 

Second, add a line of code between <Host></Host> tags:

<context path= "" docbase= "Now" debug= "0" reloadable= "true"/>


After the change is done as follows:

 

Where path is the name of the virtual directory, and if you want to display the home page with just the IP address, the key value is left blank; Debug and reloadable are generally set to 0 and true. What's actually going to change is

Docbase This amount, it specifies the folder where the default home page of the login Tomcat is located, which is designated by default as the root folder and now in the current folder, so we need to create a new today folder in the WebApps directory, Then put our own page files in the now folder. Then we need to have a index.html or index.jsp file, which is specified in the Web.xml file, in order to find the file at the beginning of the index, in the following order:

    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file> index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
    </ Welcome-file-list>

This is the setup of the Tomcat Conf/web.xml file, which means that the files we put in the now folder need to have one of the names of the top three files, so Tomcat will load the corresponding file as the default welcome home (and, of course, it can be conf/ Web.xml inside Change the name of the default home page).

The above settings are complete.


PS: If you want to change the tomcat default port, do not want to add 8080 to the back of the URL, you can also modify server.xml this file to achieve, find the following code:

<connector port= "8080" protocol= "http/1.1" connectiontimeout= "20000"
               redirectport= "8443"/>

Change the 8080 to 80 port, so you don't have to specify the port.

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.