Configure tomcat in eclipse

Source: Internet
Author: User

Transferred from:

Http://hi.baidu.com/81667/item/1b791838603a6dc31b9696bb

For developing javaee projects, commonly used tools include myeclipse, eclipse, and netbeans. I prefer eclipse, because it is much smaller than myeclipse, with fast response speed and sufficient to meet requirements, I like the simple programming style. Myeclipse adds many plug-ins, especially when projects can be automatically deployed to the Tomcat server. Copy an existing project, right-click the project, select properties, and modify web project settings to the new project name, for example, if you change login1 to login2 and deploy, the login2 project folder is automatically generated under Tomcat's webapps. In eclipse, you can create a new project and click "run, in the workspace. metadata \. plugins \ Org. eclipse. WST. server. core \ tmp1 \ wtpwebapps automatically generates login1, But if you copy this login1 directly and change it to login2, click "run" and the system will prompt that the file cannot be found because it is not a project created, not deployed in the workspace. metadata \. plugins \ Org. eclipse. WST. server. core \ tmp1 \ wtpwebapps, so it is best to automatically deploy the project to the Tomcat webapps directory. The following describes two common methods:

Prerequisites: establish the environment

Jdk1.6.0 + tomcat6.0 + eclipse Java ide Helios 3.6.1 (3.6.2 is very slow and 3.6.1 is recommended)

Installation path:

C: \ Java \ jdk1.6.0

C: \ Java \ jre1.6.0

C: \ Tomcat 6.0

C: \ javawork my eclipse workbench

E: \ eclipse \ eclipse.exe eclipse directory

Download the complete struts2.1.6 package, copy the commons-fileupload-1.2.1.jar, struts2-core-2.1.6.jar and other jar packages, used to build the struts2 Project

First, package the project *. war file. For example, in eclipse, I first created the login1 project, copied login1 and renamed it login2. After adding or modifying the class file in login2, to test whether a function can be implemented, select "Export" in the login2 project and export it as a war file, for example, name it login2.war, and copy the login2.war file to C: \ Tomcat 6.0 \ webapps, stop the Tomcat service, restart the Tomcat service, login2.war automatically decompress a folder login2, and then open http: // 127.0.0.1: 8080/login2/index. JSP can be accessed to test whether a function can be implemented. The disadvantage of this method is that if you need to modify the source code, you must repackage the modified war file and copy it to C: \ tomcat.
6.0 \ webapps and overwrite the original login2.war. If you need to modify it many times, you need to overwrite it many times. It is meaningless to do a lot of work. It is best to modify the source code every time in eclipse, restart the Tomcat service to load the new Code for testing. for how to implement this function, see the second method.

The second goal is to enable eclipse to automatically deploy the project to Tomcat's c: \ Tomcat 6.0 \ webapps, instead of to the workspace. metadata \. plugins \ Org. eclipse. WST. server. core \ tmp1 \ wtpwebapps can be implemented in a simple way.

Create a dynamic web project named zb4. Under webcontent, create a new file login. jsp, and write code in any segment, such as my

<% @ Page Language = "Java" contenttype = "text/html; charset = gb18030"
Pageencoding = "gb18030" %>
<Form action = "" method = "Post">
Username: <input type = "text" name = "username">
Password: <input type = "text" name = "password">
<Input type = "Submit" value = "login">
</Form>

See figure 1.

Click the Green run button above, as shown in figure 2.

Click Next and click Finish, as shown in figure 3.

Under servers, a tomcat v6.0 server has been added. Right-click the server and select Open to open it, as shown in figure 4.

The status of server locations is gray and cannot be modified, as shown in Figure 5.

The key is to modify it here. How can this problem be modified? Remove the project deployed in the project, as shown in figure 6.

Stop the Tomcat service, remove the zb4 project, and open it again. See figure 7.

The status of server locations is still gray and cannot be modified. Start the Tomcat service, as shown in Figure 8

Open again after startup, as shown in Figure 9

You can modify the configurations of server locations.

Configure three places:

1. Select "use tomcat installation". The default value is "use workspace metadata", as shown in figure 10;

2. After "use Tomcat insallation" is selected, the following line of server path is automatically changed to c: \ Tomcat 6.0 (tomcat installation path), which can be c: \ Tomcat 6.0;

3. Change the deploy path to "webapps". The default value is "wtpwebapps ".

Click Close in the upper right corner. In the displayed dialog box, select YES to save the settings.

At this point, the setting is complete. to copy a project, right-click Project zb4 and select Properties, select Web Project Settings and modify the project name to automatically deploy it to the webapps directory of Tomcat. See Figure 12.

Related Article

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.