Change the root context to other folder in tomcat 6

烈酒焚心 提交于 2019-11-29 16:30:36

问题


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 to www.app.mysite.com/application/dashboard

I went through post to change the root context here and here. But the thing is that i have other applications running to on that server which are accessed by

www.app.mysite.com/ps
www.app.mysite.com/ls

If i change the context path in server.xml will it affect context of my other application ?I dont want the context to change for above mentioned apps, but i want to change it for my particular application dashboard.

Is there any way to change the context of any particular application, by adding any thing to web.xml or other?


回答1:


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).




回答2:


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



来源:https://stackoverflow.com/questions/18873063/change-the-root-context-to-other-folder-in-tomcat-6

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!