Posted In: Server, Tomcat

How to set the context path of a web application in Tomcat 9

How to set the context path to “/” or root of a web application in Tomcat 9
Deploying my application at the root in Tomcat

1. Setting context path using Eclipse

 

Set context path in server web module

 

Set context path in Web project settings

 

2. Setting context path “/” directly on Tomcat server

Option 1 – Delete all ROOT application folder from webapp and rename your application as ROOT.war and deploy.

Option 2 – Add ROOT.xml to TOMCAT E:\programs\tomcat9\conf\Catalina\localhost. Restart the server

 <Context 
  docBase="E:/apps/Example20176" 
  path="" 
  reloadable="true" 
/>

 

3. Setting context path using Apache HTTP Reverse proxy. This approach should be used in an enterprise application.

In case you have Apache HTTP server available you could use ProxyPass module to pass request to any context


Uncomment proxy modules on Windows. Follow guide to set proxy on your machine.
LoadModule headers_module modules/mod_headers.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so

Then use following  
ProxyPass / http://localhost:8080/example/
ProxyPassReverse / http://localhost:8080/example/

by , on August 26th, 2017

  • Categories