Sto utilizzando tomcat 6 e ho due webapp. Uno è webapp1 e l'altro è webapp2. Da un filtro all'interno di webapp2, sto cercando di accedere all'altra webapp i.e webapp1. Il mio codice filtro è qualcosa di simile sottoTomcat non è in grado di ottenere ServletContext di un'altra webapp
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);
}
Qualunque idea cosa sto facendo male? Ricevo sempre null come valore di othercontext.