Why not just include <a> tags in your w1 webapp's pages whose href
attributes point direct to URIs that begin "/w2app/" and vice-versa?  I
don't think you need to use dispatchers.

The docs for ServletContext#getContext (your line 1) say: "...The given path
must be begin with "/", is interpreted relative to the server's document
root and is matched against the context roots of other web applications
hosted on this container. In a security conscious environment, the servlet
container may return null for a given URL.".

The spec says ServletContext#getContext "Returns: the ServletContext object
that corresponds to the named URL, or null if either none exists or the
container wishes to restrict this access."

So:

1. Are you sure that your url begins with a "/" ?

2. If you are, the null indicates that there is a security constraint
preventing access to the URL (or the url does not exist). This could be a
standard TC rule preventing access between webapps.  I don't know for sure,
perhaps someone that knows more will chip in.

> -----Original Message-----
> From: Nihita Goel [mailto:[EMAIL PROTECTED] 
> Sent: Thursday 27 October 2005 13:33
> To: users@tomcat.apache.org
> Subject: How to share resources across two applications
> 
> 
> Hi,
> I have two applications running on the tomcat application server.
> w1 - with context path "/w1app"
> and w2 with context path "/w2app"
> I wish to provide links in w1 displaying pages of w2.
> 
> I have used this code in my HttpServlet class of w1
> 
> if  /// some condition
> 
> Servlet Context othercontext = 
> getServletContext().getContext("/w2app"); 
> (1)
> RequestDispatcher rd = othercontext.getRequestDispatcher(url); (2)
> rd.forward (request,response) (3)
> 
> However - the it gives a NullPointerException at 1.
> 
> I have been trying hard but without success..
> 
> Thanks



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to