I created a collection of template jsps that i want to use in different implementations of an application. In the implementation application i have a servlet that reads an xml document and based on this document includes pages from the template application. I am having problems including pages from a different web app. I use the RequestDispatcher, but the html that is displayed does not include any of the jsps. if i put the jsps into my implementation web application then everything works fine. My question is how do i include jsps from another web app Thanks, Steve
Originally posted by Steve Chernyak: I am having problems including pages from a different web app. I use the RequestDispatcher, but the html that is displayed does not include any of the jsps.
Easy - once you know how (but isn't everything ). When you retrieve a RequestDispatcher from the request object, it delegates this call to the ServletContext (ServletContext.getRequestDispatcher(String)), i.e. the web application. The dispatcher can only dispatch requests to servlets inside its web application. To dispatch a request to a different application on the same server, call ServletContext.getContext(String) first. This will give you the context for the other web application. The argument is the path to the root of the other web-app. Once you have this context, you can use it retrieve a request dispatcher valid for that other application. Assuming you want to forward/include "/myotherapp/servlets/myotherservlet":
HTH - Peter
[This message has been edited by Peter den Haan (edited June 16, 2001).]