Change the root context to other folder in tomcat 6

前端 未结 2 1585
闹比i
闹比i 2021-01-01 09:24

I want to change the context of my deployed web application. Currently it is accessed by the url www.app.mysite.com/dashboard

But i want to change it t

相关标签:
2条回答
  • 2021-01-01 09:49

    I doubt whether this is possible in tomcat. Best would be to use apache http server or else, create two applications one with context root application (dummy application) with a servlet to route all the request to dashboard.

    Let me know if you are able to do this in tomcat in a better way

    0 讨论(0)
  • 2021-01-01 10:08

    This is a way to do it (step-by-step):

    1. Put your expanded WAR in a directory outside of webapps. My TOMCAT_HOME is /home/nikos/apache-tomcat-6.0.37 and I placed my app in the folder myapp under a new folder: $TOMCAT_HOME/webapps-manual. I.e. the folder structure is:

      $TOMCAT_HOME
      |
      +- ...
      |
      +- webapps (NOT HERE!!!)
      |
      +- webapps-manual
         |
         +- myapp
            |
            +- index.jsp
            |
            +- WEB-INF
               |
               +- web.xml (optional)
      
    2. Edit TOMCAT_ROOT/conf/server.xml. Add the following <Context> under the appropriate <Host> element (there is probably only one):

      <Host ...>
          <Context
              path="/application/dashboard"
              docBase="/home/nikos/apache-tomcat-6.0.37/webapps-manual/myapp"
          />
      </Host>
      
    3. DONE! Open http://localhost:8080/application/dashboard/index.jsp and see content generated by $TOMCAT_HOME/webapps-manual/myapp/index.jsp.

    See relevant documentation here (see attributes path and docBase).

    0 讨论(0)
提交回复
热议问题