http://topic.csdn.net/t/20060112/18/4513558.html如果需要把请求转移到另外一个Web   App中的某个地址,可以按下面的做法:   
       
    1.   获得另外一个Web   App的ServletConext对象(currentServletContext.getContext(uripath)).   
       
    2.   调用ServletContext.getRequestDispatcher(String   url)方法。
请叫怎么样获得另外一个Web   App,有谁指点一下?

解决方案 »

  1.   

    可以吧,比如我的tomcat webapp下有两个应用:
    crm/
    frm/在crm的应用中就可以跳转到frm的,比如:
    response.sendRedirect("../frm/login.jsp");
      

  2.   

    request.getRequestDispatcher(url).forward(request,response)
    这种方式是应用内的转向
    想跳到另外一个应用可以用sendRedirect方式
      

  3.   

    怎么样获得另外一个Web   App,有谁指点一下?
      

  4.   

    sureyor() :
    可以吧,比如我的tomcat webapp下有两个应用:
    crm/
    frm/你这个应该是虚拟目录,属于同一应用吧?
      

  5.   

    两个不同的应用,但在同一个Web Container下面
      

  6.   

    frm/
       /css
       /js
       /jsp
       /WEB-INF
       login.jsp
       
    crm/
       /css
       /js
       /jsp
       /WEB-INF
       login.jsp
      

  7.   

    ServletContext.getRequestDispatcher(String   url)这里的url是代表你可以用IE访问到的路径,你要是想指定相应的东西,给个http://IP:端口号/应用名/相对路径就好了,把这个字符串给设为url传进去就好了
      

  8.   

    sureyor():
    我不能使用跳转:response.sendRedirect("../frm/login.jsp");你能够使用
    request.getRequestDispatcher实现吗?<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false" /><Host name="www.xxx.com" appBase="webapps1" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false" /><Host name="www.yyy.com" appBase="webapps2" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false" />
    我想在www.xxx.com里面的某个Servlet使用request.getRequestDispatcher到www.yyy.com里面的某个文件去。
      

  9.   

    不是一个应用不能用forward,forward是基于当前应用的
      

  10.   

    1.   获得另外一个Web   App的ServletConext对象(currentServletContext.getContext(uripath)).   
    2.   调用ServletContext.getRequestDispatcher(String   url)方法。我想问问以上的具体实现代码,谢谢。