The index. jsp Homepage cannot be accessed.

Source: Internet
Author: User

The index. jsp Homepage cannot be accessed.

Solution:

Tomcat: add the project to it

Deploy the webapp directory for unpacking

One of the methods to deploy a Web project to Tomcat is to deploy a Web project that is not encapsulated in the WAR file. To use this method to deploy the unpackaged webapp directory, you just need to put our project (Compiled release project, non-development project) under the Tomcat webapps directory. As shown in:

In this case, open the Tomcat server (make sure the server is enabled) And you can access our project in the browser, as shown in:

But at this time, we found that when accessing our project content, we must add our project name "myweb", which is very bad. If you want to directly access http: // localhost: 8080/index.html without adding the project name, as follows:

We found a 404 error. If we want to access our project through the above connection, We can edit conf/server. xml for configuration.

Open the server. xml file and find the Host element. The default configuration is as follows:

We need to add the Context content inside the Host. The added content is as follows:

In this case, you can access http: // localhost: 8080/index.html without adding the project name. As follows:

(In fact, this can still be accessed through the http: // localhost: 8080/myweb/index.html address .)

Ii. Package war files

In this way, you only need to put the packaged war file under the webapps directory. As shown in:

When we start Tomcat, The first thing Tomcat needs to do is to unpack the war file content to the path with the same file name and retrieve it. war extension, and then read the project file from the unwrapped directory. Now, start Tomcat, as shown in:

We can see that there is an extra myweb folder under the webapps directory. Then, you can use http: // localhost: 8080/myweb/index.html in the browser. If you want to access http: // localhost: 8080/index.html, you also need to configure the server. xml file. The operation steps are the same as those described above and are no longer repeated.

Iii. Manager Web

The Manager Web source application allows us to manage our Web projects through the Web. Of course, if anyone can manage other people's projects, things will become a little tricky, not to mention security protection. Therefore, when we want to manage our projects through the Manager Web, we need to set permissions.

First, visit the Apache Tomcat welcome page.

At this time, we click the section in the circle in the figure and will prompt us to enter the user name and password. Therefore, we need to add a role in the conf/tomcat-users. xml file. Tomcat-users. xml does not add any roles by default. Because we want to manage our projects through the Manager Web, we add the manager-gui role in it. As shown in the following figure (the role we added is in the circle, username is left blank, password is left blank, and roles is filled with the manager-gui below ):

After configuring this, restart the server and you will be able to access the management interface.

On the Server Status page, you can view the Server Status and Tomcat information, including the Tomcat version, JVM version, and JVM provider. For example:

Go to the Manager App page to manage our projects. Shows the page:

Applications displays the project directories under the webapps Directory: ROOT directory, doc directory, and manager directory. These are all built-in Tomcat. At this time, we do not have our own projects. Now we start to deploy our own projects. In Deploy, we can see two methods: 1. Deploy directory or WAR file located on server; 2.WAR file to deploy.

First, we will demonstrate how to use WAR file to deploy.

Myweb. war is a packaged project file. Click "select file" to select a project file on our host. This file can be stored in any location. If it is stored in webapps, Tomcat will be directly decompressed when Tomcat is started. If it is placed elsewhere, Tomcat will copy the myweb. war file to the webapps directory and decompress it when Tomcat is started. Select a file and click Deploy to publish the file. At this time, you can access it via http: // localhost: 8080/myweb/index.html in the browser.

At this time, let's take a look at the changes in the Manager App page, such as the section in the middle circle, with the myweb project we just released missing.

Next, Deploy directory or WAR file located on server. Copy myweb. war to the webapps Directory, enter \ myweb in the WAR or Directory URL, and click Deploy.

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.