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.

0

Just remove ROOT directory in webapps and adjust context like this

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

Then restart Tomcat.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.