Best way to have tomcat app in /

At work, we have many Spring applications running on the same tomcat server. Some of the applications have their own domains with a virtual host in apache, which rewrites requests from / url to / context_root / url.

This is good and good, except when I use some lib springs tags that process URLs. An example is the <form:form> , which creates the / context _root / form action and takes the user away from /. Now the application is still working when this happens, but the management does not want to see the root of the context.

What is the best way to handle this?

0
spring-mvc apache
source share
1 answer

In case someone stumbles about it, I really found the answer.

With Tomcat you can have multiple hosts . Therefore, I configure the host with my application as the default web application. Here is an example:

Add another host to server.xml

 <Host name="lilhug.mydomain.com" appBase="lilhug" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"/> 

Create multiple files and directories

 mkdir $CATALINA_HOME/lilhug mkdir $CATALINA_HOME/conf/Catalina/lilhug.mydomain.com 

If you want a Tomcat manager for this host

 cd $CATALINA_HOME/conf/Catalina cp localhost/manager.xml lilhug.mydomain.com 

Then restart tomcat and you are good. Deploy the lilhug application on / using /manager running on your new host, or copy the war to $CATALINA_HOME/lilhug/ROOT.war

0
source share

All Articles