Reputation: 267049
Netbeans always deploys the .war of my application to /MyProject on Tomcat. This means that I view them on http://localhost:8084/MyProject
, and all links such as /something
don't work as they point to http://localhost:8084/something
rather than http://localhost:8084/MyProject/something
. How can I get Netbeans to instead deploy the application to the root of Tomcat?
Upvotes: 1
Views: 2547
Reputation: 2241
I know this might be 4 years late, but I found an easier solution.
Go to META-INF/context.xml
in your netbeans project and you should find something like:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/myProject"/>
Change the Context path
to:
<Context path="/"/>
This will deploy your project as root.
Upvotes: 0
Reputation: 61128
By default, when deploying an application, tomcat deploys ApplicationName.war
as /ApplicationName
.
Another thing to note is that an application called ROOT
is served as the root (i.e. /
).
Therefore the solution is fairly simple - deploy your warfile as ROOT.war
and tomcat will automatically serve it as /
·
Upvotes: 2
Reputation: 11486
That should be in your context.xml. The details of the configuration are here http://tomcat.apache.org/tomcat-7.0-doc/config/context.html. Moreover, the context.xml is accessible within the /META-INF/context.xml path. I don't think that NetBeans will do that for you. We have to specify that ourselves, just like in GlassFish where I had to do the same thing in a glassfish-web.xml file.
Upvotes: 3
Reputation: 2842
You can specify a context root of "/" but I don't believe this can be done in a platform independent way. See this question for more details:
How do you specify the root context in your <web-app> tags in web.xml?
Upvotes: 1