0

I want to redirect tomcat to directly open my application. Example: http://localhost:8080/myapp should directly open as http://localhost:8080/.

I read various articles and solutions from the web and tried to change the context path in server.xml, also I tried an ugly method of renaming the ROOT folder as ROOt_old and renaming 'myapp' folder as ROOT.

Here is the Hosts section from my server.xml

<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">


        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

        <Context path="" docBase="C:/Program Files (x86)/Apache Software Foundation/Tomcat 8.5/webapps/myapp">
                    <WatchedResource>WEB-INF/web.xml</WatchedResource>
        </Context>

      </Host> 

However, this does not work and when I try to open http://localhost:8080/ , I get a 'Page cannot be displayed' error as well as the URL is empty in the address bar.

Shravan
  • 1
  • 1
  • 1
  • 1

1 Answers1

0

Just remove the ROOT directory in web apps and adjust the context like this:

path="/" docBase="C:/Program Files (x86)/Apache Software Foundation/Tomcat 8.5/webapps/myapp">

<WatchedResource>WEB-INF/web.xml</WatchedResource>

Then restart Tomcat.

Note: Be careful with space in the windows path (replace them with \ if it didn't work).

Iman
  • 113
  • 9
hnajib
  • 56
  • 1