In Eclipse Oxygen I have set up a Web project (facets Dynamic Web Module, Java & JavaScript) with the name MyProject.

When I start up Eclipse's Tomcat (Version 8.5) I can view the site under the project URL http://localhost:8080/MyProject/. So far so good. But how can I configure the Eclipse project that the server's base URL http://localhost:8080 redirects to the project URL?

Bonus question: Is there a way to change the path in the URL without changeing the project name, so that the project URL is, say, http://localhost:8080/FancyOtherName/ instead of http://localhost:8080/MyProject/?

1

There are 1 answers

5
Scott On

So there are a few options here. You could deploy the application in the root context of the server to get rid of the MyProject in the URL altogether. There are a few ways to do this, but the easiest is to have the .war file from your build be name ROOT.war. This will deploy the application in the server's root context and will get rid of MyProject from the URL. To change the context of the application in your projects URL, you could do so through some configuration of the application (which I don't have enough details to comment on), or through the Tomcat configuration. By deploying the application with the ROOT.war MyProject will be removed from the URL, but you could add <Context path="" docBase="FancyOtherName"></Context> to the $CATALINA_HOME\conf file in the <Host> tag as well as adding to autoDeploy="false" and deployOnStartup="false" to the host tag so it looks something like this <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="false" deployOnStartup="false">. This will stop the application from deploying twice, once in the root context and once at http://localhost:8080/FancyOtherName/, and will only deploy the application at http://localhost:8080/FancyOtherName/. Good Luck!