Saturday, October 3, 2009

Change default ROOT folder in TOMCAT

When you type http://localhost:8080/ you load the default index.html which is present in C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\ROOT. To change this behavior you need to change the redirection to ROOT folder. In order to do that you can implement either of the four options:-
  1. Html redirection from C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\index.html to C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\MYAPPLICATION\index.html
    Modify index.html in C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\ROOT as follws:-

    <html>
    <head>
    <title>Redirecting to /MYAPPLICATION</title>
    </head>
    <body onLoad="javascript:window.location='MYAPPLICATION';">
    </body>
    </html>

    Or

    <html>
    <head>
    <title>Redirecting to /MYAPPLICATION</title>
    <meta http-equiv="refresh" content="0;url=MYAPPLICATION" />
    </head>
    <body>
    </body>
    </html>

    NB: MYAPPLICATION is in webapps folder

  2. Add/change context in C:\Program Files\Apache Software Foundation\Tomcat 6.0\conf\server.xml inside <Host> tag as follows:-

    <Context path="" docBase="{relative path of MYAPPLICATION folder (relative to webapps folder)} OR {absolute path of MYAPPLICATION folder with backslash or frontslash}" debug="0" >
    </Context>

    NB: Can keep MYAPPLICATION folder anywhere in the computer
    NB: Can leave ROOT folder as it is

  3. Create ROOT.xml in C:\Program Files\Apache Software Foundation\Tomcat 6.0\conf\Catalina\localhost as follows:-

    <Context path="" docBase="{relative path of MYAPPLICATION folder (relative to webapps folder)} OR {absolute path of MYAPPLICATION folder with backslash or frontslash}" debug="0" >
    </Context>

    NB: Should keep MYAPPLICATION folder outside webapps folder anywhere in the computer
    NB: ROOT.xml (should be UPPERCASE)
    NB: Can leave ROOT folder as it is

  4. Delete ROOT folder under C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps and rename MYAPPLICATION to ROOT

4 comments:

  1. Dear admin your post really helped me a lot ,thanks for the wonderful information

    ReplyDelete
  2. Thank you very much ,very help me

    ReplyDelete
  3. Thanks again easy to understand Save my life T^T

    ReplyDelete
  4. Thanks friend,
    This helped me a lot!!!!!

    ReplyDelete