aspose file tools*
The moose likes Servlets and the fly likes including jsps from another web app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "including jsps from another web app" Watch "including jsps from another web app" New topic
Author

including jsps from another web app

Steve Chernyak
Ranch Hand

Joined: Oct 19, 2000
Posts: 113
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
Julia Reynolds
Ranch Hand

Joined: May 31, 2001
Posts: 123
I know you can't do that from some Servlet Containers. Servlet Mill, the servlet engine that comes with Persistence PowerTier, will absolutely not allow this, I believe.
Julia
Steve Chernyak
Ranch Hand

Joined: Oct 19, 2000
Posts: 113
Thanks Julia,
I am using WebLogic 6, has anybody done this with WebLogic
Thanks
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
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).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: including jsps from another web app