How to configure tomcat in myeclipse

Source: Internet
Author: User
I. Tomcat server

Open-source project of Apache Jakarta

JSP/servlet container

Default port: 8080

1. Start and Stop

Startup. BAT: Start the Tomcat batch file

Shutdown. BAT: batch files for stopping the Tomcat service and releasing resources

1. Start the service


2. Close this window to close the Tomcat service.

Shortcut: Ctrl + c

3. Sometimes the port is occupied. Remember the exception when the port is occupied:

 

Severe: Catalina. Stop:

Java.net. connectexception: Connection refused: connect

At java.net. plainsocketimpl. socketconnect (native method)

At java.net. plainsocketimpl. doconnect (plainsocketimpl. Java: 333)

At java.net. plainsocketimpl. connecttoaddress (plainsocketimpl. Java: 195)

At java.net. plainsocketimpl. Connect (plainsocketimpl. Java: 182)

At java.net. sockssocketimpl. Connect (sockssocketimpl. Java: 366)

At java.net. Socket. Connect (socket. Java: 529)

At java.net. Socket. Connect (socket. Java: 478)

At java.net. Socket. <init> (socket. Java: 375)

At java.net. Socket. <init> (socket. Java: 189)

At org. Apache. Catalina. startup. Catalina. stopserver (Catalina. Java: 422)

At sun. Reflect. nativemethodaccessorimpl. invoke0 (native method)

At sun. Reflect. nativemethodaccessorimpl. Invoke (nativemethodaccessorimpl. Java: 39)

At sun. Reflect. delegatingmethodaccessorimpl. Invoke (delegatingmethodaccessorimpl. Java: 25)

At java. Lang. Reflect. method. Invoke (method. Java: 597)

At org. Apache. Catalina. startup. Bootstrap. stopserver (Bootstrap. Java: 337)

At org. Apache. Catalina. startup. Bootstrap. Main (Bootstrap. Java: 415)

Severe: Error initializing endpoint

Java.net. bindexception: address already in use: jvm_bind <null>: 8080

At org.apache.tomcat.util.net. jioendpoint. INIT (jioendpoint. Java: 509)

At org. Apache. Coyote. http11.http11protocol. INIT (http11protocol. Java: 176)

At org. Apache. Catalina. connector. connector. initialize (connector. Java: 1058)

At org. Apache. Catalina. Core. standardservice. initialize (standardservice. Java: 677)

At org. Apache. Catalina. Core. standardserver. initialize (standardserver. Java: 795)

At org. Apache. Catalina. startup. Catalina. Load (Catalina. Java: 535)

At org. Apache. Catalina. startup. Catalina. Load (Catalina. Java: 555)

At sun. Reflect. nativemethodaccessorimpl. invoke0 (native method)

At sun. Reflect. nativemethodaccessorimpl. Invoke (nativemethodaccessorimpl. Java: 39)

At sun. Reflect. delegatingmethodaccessorimpl. Invoke (delegatingmethodaccessorimpl. Java: 25)

At java. Lang. Reflect. method. Invoke (method. Java: 597)

At org. Apache. Catalina. startup. Bootstrap. Load (Bootstrap. Java: 260)

At org. Apache. Catalina. startup. Bootstrap. Main (Bootstrap. Java: 412)

2012-9-26 9:34:59 org. Apache. Catalina. startup. Catalina Load

Use the log file generated in the % atat_home % \ logs directory

4. Now, you can use shutdown. BAT to release the port.

2. Test Tomcat

Enter http: // localhost: 8080 or http: // 127.0.0.1: 8080 in the address bar. If the following interface is displayed, the operation is successful.

3. Configure the Tomcat port number

In the % atat_home % \ conf directory, open servlet. XML in the text editor and find

 

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

Connectiontimeout = "20000"

Redirectport = "8443" type = "regxph" text = "yourobjectname"/>

Just change port = "8080" to the port you want.

Suggestion:Use a number larger than 1024.

4. Deploy the application

Two methods:

1. Manually deploy to webapps

Copy the web application to webapps under the Tomcat directory

2. virtual directory

In the % atat_home % \ conf directory, use a text editor to open servlet. xml and configure it in the host tab:

 

<Context Path = "/myweb" docbase = "H: \ 2t100 \ jspservlet \ myweb" reloadable = "true"/>

A context represents a web application,

Path: Virtual Path

Docbase: physical path of the web program

Reloadable: automatically reload page changes

Ii. directory structure of web programs

 

Directory

Description

/

The root directory of the Web application.

Client Access, including JSP, HTML, and jpg

And other resources.

WEB-INF

Stores various resources used by applications.

Directory is not accessible to the client, including

Web. XML (deployment descriptor)

/WEB-INF/classes

Store all the class files of the WEB Project

/Web-INF/lib

Store Jar files used by Web Applications

3. Manage Web applications in Tomcat

Click tomcatmanager.

Enter user name and password

Configure the user and password

Click "cancel" in, and the following message is displayed:

Then modify CONF/tomcat-users.xml

Add users in the format

 

<User Username = "Tomcat" Password = "123" roles = "Admin, Manager"/>

Enter the user name and password

Go to the Management page:

4. Configure tomcat4.1. in eclipse

Select windwo à preferences

Select myeclipse

Select servers

Select Tomcat

Use version 6.x

Select enable

Select Tomcat path

Apply)

The newly configured Tomcat items are displayed in the Server View.

You can also configure it in the shortcut key.

Select confing Server

Open configuration window

4.2. Deployment Project

1. Deploy in the shortcut menu

Open the deployment window and select the server to deploy.

Click Add to add a project. The project drop-down box displays a web project that can be deployed.

2. Deploy in the servers view

If the servers view is not displayed, open the servers view.

If the servers view option is not displayed in the preceding options, you can select other and select servers in the other window.

You can either right-click the menu or use the shortcut tool in the servers view to deploy

4.3. Project name and deployment project name

1. Select project properties or press the shortcut key Alt + enter

2. Select myeclipse à Web

Web context-root is the name after deployment. Note: It starts "/".

 

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.