Java 无法将请求从一个Web应用转发到另一个Web应用

Java 无法将请求从一个Web应用转发到另一个Web应用,java,Java,当我尝试使用以下代码通过筛选器将请求从一个Web应用程序转发到另一个Web应用程序时,出现以下错误: ServletConfig sc=getServletConfig(); javax.servlet.ServletContext otherCtx = sc.getServletContext().getContext("/pharmacy"); otherCtx.getRequestDispatcher(forwardUrl.substring(forwardUrl.indexOf('/'

当我尝试使用以下代码通过筛选器将请求从一个Web应用程序转发到另一个Web应用程序时,出现以下错误:

ServletConfig sc=getServletConfig(); 
javax.servlet.ServletContext otherCtx = sc.getServletContext().getContext("/pharmacy");
otherCtx.getRequestDispatcher(forwardUrl.substring(forwardUrl.indexOf('/',1))).forward(pRequest, pResponse);
但我能看到一个空白页。谁能给我一个建议吗

ERROR [[default]] Servlet.service() for servlet default threw exception java.lang.NullPointerException  at atg.servlet.minimal.MinimalContainerUtil.dispatchToDynamoPipeline(MinimalContainerUtil.java:334)     at atg.servlet.GenericRequestDispatcher.forward(GenericRequestDispatcher.java:534)
你在雄猫手下吗?
如果是这样,请在上下文xml文件中添加一个属性:crossContext=true

如果
/pharmacy
位于不同的web应用程序中,则您的筛选器将不知道有关它的任何信息,因此无法执行服务器端重定向

使用
response.sendRedirect