I am using tomcat 6 and I have two webapps. One of them is webapp1, and the other is webapp2. From the filter inside webapp2 I am trying to access another webapp ie webapp1. My filter code looks something like
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest)request;
System.out.println("requeted path = " + req.getRequestURI());
ServletContext othercontext = confg.getServletContext().getContext("/webapp1");
RequestDispatcher dispatcher = othercontext.getRequestDispatcher(req.getRequestURI());
dispatcher.forward(request, response);
chain.doFilter(request, response);
}
Any idea what I'm doing wrong? I always get null as the value of othercontext.
source
share