Hi all,
 
Deploying 3 web-apps in one container. Outside, Inside and Admin. Outside is mostly static, with a login section. The login section takes the user to the Inside app. This all works. Problem occurs when I try to get a user to forward to a JSP page in the outside application. Using my MVC framework, I get a RequestDispatcher for the forwarding URL which is a "relative" URL to the web-app its in. I figured out by using SerlvetContext.getContext(url) to get the ServletContext of any web-app running, but using that ServletContext's RequestDispatcher doesn't seem to allow me to forward to a JSP page in that context. For example:
 
 
 
/ = outside web app
/inside = inside web-app
/admin = admin web-app
 
 
Lets say we are in the ControllerServlet of the /inside web-app:
 
request.getContextPath()   = /inside
 
I want to forward TO the outside web-app index.jsp page. I have /index.jsp, /inside/index.jsp, and /admin/index.jsp. I do the following bit of code to forward from within the /inside web-app context to the / outside index.jsp page:
 
ServletContext sc = getServletContext().getContext("/index.jsp");
 
This correctly gives me the / context, as I tested this by having the /index.jsp page set an attribute, and in the ControllerServlet I can successfully get that attribute.
 
Now, this call always results in a 404 error:
 
sc.getRequestDispatcher("/index.jsp").forward(reuqest,response);
 
 
Ideally, since the "/index.jsp" indicates its in the / (root or outside) context, it should forward to the index.jsp page in this context. On the other hand, because I already have a ServletContext of the outside app, perhaps just "index.jsp" is used. I tried this and still get 404 error.
 
So, any ideas why, or how, to forward from a servlet running in one web-app, to a servlet/jsp page in another web-app? I know according to the spec you can't pass data among web-apps (other than through JNDI), but I sure would like to separate our outside, inside and admin sites into their own WAR files, but still be able to move from one web-app to another. If I kept it all in a single web-app, then using the paths of /admin, /inside or / would work fine. So I am unclear as to why getting the ServletContext of any given web-app OR just trying to forward to a path using the relative "root" path, would work. The API is not exactly clear on how this works.
 
Thanks.

Reply via email to