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?
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.
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.
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With