What happens when Eclipse calls Tomcat?

Source: Internet
Author: User
Tags tomcat server

In the afternoon, looking at the Tomcat guide, I came up with the question: What happens when I call a tomcat on my computer to run a Web project in eclipse?

Prior to the completion of the undergraduate program was MyEclipse, when the Tomcat server was configured, after running a Web project, you can see my deployed projects under the WebApps folder of Tomcat, for example, my project is called HelloWorld, Then I will see a folder in the WebApps directory, named HelloWorld, this folder is my Web site. When Tomcat is running, I can access and manage my project on the Tomcat page. For example, my Tomcat URL is http://localhost:8080, then my project can be accessed through Http://localhost:8080/helloworld. This is because MyEclipse will copy my project to the Tomcat WebApps directory.

And when I used Eclipse , things changed.

First, I don't see the project I deployed under Tomcat's WebApps directory, nor in the Wtpwebapps directory. Secondly, I found so many parameters "-dcatalina.base=" E:\Workspaces\EclipseJ2EE\.metadata\ in the configurations of Tomcat configuration in Eclipse. PLUGINS\ORG.ECLIPSE.WST.SERVER.CORE\TMP2 "-dcatalina.home=" D:\Servers\tomcat7 "-dwtp.deploy=" E:\Workspaces\ Eclipsej2ee\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps "-djava.endorsed.dirs=" D:\Servers\ Tomcat7\endorsed "", while according to the parameter "E:\WORKSPACES\ECLIPSEJ2EE\.METADATA\.PLUGINS\ORG.ECLIPSE.WST.SERVER.CORE\TMP2" This path found a folder similar to Tomcat and found my project in the Wtpwebapps directory. What the hell is going on here?

I did not know when I read some information on the Internet:

When Eclipse started Tomcat, it called the Javaw.exe program in the JDK and added the parameters I saw above. Here's a look at the main parts of these parameters:

    • Dcatalina.base: It specifies the location of the catalina.base. Tomcat allows multiple instances to run, and Catalina.base is the working directory for each instance, which is the working directory of the Tomcat instance that we launched in Eclipse. Its directory structure is very similar to the structure of the Tomcat installation directory, except that it has no bin and Lib directories.
    • Dcatalina.home: This parameter is the installation directory of Tomcat, which is the common directory owned by each Tomcat instance.
    • Dwtp.deploy: This is the path where you deploy the project. For example, my HelloWorld project is under the folder specified in this parameter.

At this point, if you visit http://localhost:8080 will prompt 404, cannot find the page, but Http://localhost:8080/helloworld can access to my project. Look at the Server.xml file under the Conf folder, find the host tag, and you can find the following code:

<HostAppBase= "WebApps"Autodeploy= "true"name= "localhost"Unpackwars= "true"><ContextDocBase= "E:\Workspaces\EclipseJ2EE\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps\ROOT"Path=""reloadable= "false"/><ContextDocBase= "E:\Workspaces\EclipseJ2EE\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps\HelloWorld" Path= "/helloworld"reloadable= "true"Source= "Org.eclipse.jst.jee.server:HelloWorld"/></Host>

  The first context indicates root, but there is no file under this path, so access to http://localhost:8080 is not a page. And the following context is my HelloWorld project, which indicates the path and the project file under the path, so it can be accessed.

Of course, these configurations are just the configuration of this Tomcat instance launched by Eclipse, and if we do not use eclipse to start Tomcat directly in the Tomcat installation directory, then we can access the main page of http://localhost:8080. and to monitor Tomcat on the web.

Finally, attach a picture explaining where Tomcat is configured in Eclipse. To modify the above mentioned parameters, just click on the middle of the Open launch configuration, in the popup dialog to find the arguments tag, you can modify it inside. Of course you can also make changes in the server Locations , just need to first right-click on the tomcat server in the server view ... Before you can edit it.

Report:

With regard to JAVAW, it is a Win32 GUI application that helps the application to start its own GUI interface without launching the consoles console interface. For example, start eclipse will use this JAVAW program, and start a output "Hello" text program will only use Java.exe just fine.

  

What happens when Eclipse calls Tomcat?

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.