Click Upvote Click Upvote - 19 days ago 5
Java Question

How to get Netbeans to deploy Java web app to Tomcat's Root (e.g /) instead of /MyProject?

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?

Answer

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.