Home > Back-end >  Why URL mapping for tomcat has to have application name inside?
Why URL mapping for tomcat has to have application name inside?

Time:09-08

When I deploy an application named let's say App with a servlet Servlet with tomcat, then I can access it using URL localhost:8080/App/Servlet. Why not localhost:8080/Servlet? Can I configure it so that /Servlet redirects to /App/Servlet?

CodePudding user response:

Just deploy your web application with the special name ROOT.

That'll be either in tomcat/webapps/ROOT or tomcat/webapps/ROOT.war (unless you deploy in a different way). Note: If memory serves me right, then those have to be capital letters for ROOT, even on Windows

Another option is to bring the configuration into Tomcat's context.xml, in your web-application's META-INF/context.xml (see "path" in the docs)

  • Related