Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

including jsps from another web app

 
Steve Chernyak
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Julia,
I am using WebLogic 6, has anybody done this with WebLogic
Thanks
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic