Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

deploy webapp from Eclipse to Tomcat root context

I deploy a .war application from Eclipse by adding the "Dynamic Web Module" facet, then right-clicking on the project and selecting "Run As -> Run on Server".

This works great, but by default the project is deployed to the /web context of Tomcat, because the project name is web. Is there a way I can deploy from Eclipse to Tomcat without changing the project name to ROOT?

like image 866
Dónal Avatar asked Jul 12 '11 13:07

Dónal


People also ask

How do I change the context root of a web application in Eclipse?

To change the context root of a web application that is already available in the Eclipse workspace, simply right-click on the web project and call the “Properties” action from the context menu.

Where is the context root of a web application in Tomcat?

The context path refers to the location relative to the server's address which represents the name of the web application. By default, Tomcat derives it from the name of the deployed war-file. So if we deploy a file ExampleApp. war, it will be available at http://localhost:8080/ExampleApp.

How do you set root context?

A context root identifies a web application in a Java EE server. A context root must start with a forward slash (/) and end with a string. In a packaged web module for deployment on the GlassFish Server, the context root is stored in sun-web.


Video Answer


2 Answers

Right click on your project in Eclipse and select Properties->Web Project Settings. Change context name there.

Alternatively you can edit it in .settings/org.eclipse.wst.common.component file inside your project

like image 37
maximdim Avatar answered Sep 23 '22 05:09

maximdim


You need to go to Server View.. double click on tomcat, this opens a new window (with 2 tabs). Select the one which says Modules, your application would be listed there (with the context path). You can change the context path from /web to anything else from here.

Alternatively, you can open server.xml look for a tag called context. within this tag you'll find the contextroot as /web.. change it.

like image 196
Anantha Sharma Avatar answered Sep 21 '22 05:09

Anantha Sharma