I am using tomcat 6 and I have two webapps. One is webapp1 and the other one is webapp2. From a filter inside webapp2, I am trying to access the other webapp i.e webapp1. My Filter code is something like below
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 am doing wrong ? I am always getting null as the othercontext value.