It's not a secret anymore!
The moose likes Tomcat and the fly likes cross context in tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "cross context in tomcat" Watch "cross context in tomcat" New topic

cross context in tomcat

sam prochazka

Joined: Dec 14, 2002
Posts: 3
My server.xml is as follows:
<Host name="localhost" debug="0" appBase="c:/RealPageMaker/webapps" unpackWARs="false">
<Context path="" docBase="webapp1" debug="0" crossContext="true"/>
<Context path="/webapp2" docBase="webapp2" debug="0" crossContext="true"/>
The .jsp code in webapp1 is as follows:
<% ServletContext thatctx= application.getContext("/webapp2");
RequestDispatcher rdpt=thatctx.getRequestDispatcher("/test.jsp");
rdpt.forward(request, response); %>
This does not work, but the following does (with an HTML page):
<% ServletContext thatctx= application.getContext("/webapp2");
RequestDispatcher rdpt=thatctx.getRequestDispatcher("/test.htm");
rdpt.forward(request, response); %>
What am I doing wrong? Is this a tomat bug? Has anyone got this working with tomcat 4.1.12?
Sam P.
laxmi Narayana

Joined: Jul 02, 2004
Posts: 1
Please Check the Jsp page folder whether it is in folder direct to it or use web.xml file to configure the url pattern for the jsp so that you could forward the request.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Have you tested to insure that the other application is running properly?
Can you hit the JSP or HTML page on the other app directly, with a browser?

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: cross context in tomcat
It's not a secret anymore!