I cannot use simple href tags in w1 application coz this application has a single controller Servlet where all requestes are received and then authenticated and other checks .. if all is well it calles the respective page.

w2 application has no security restrictions as of now - I just want a few pages from there to be displayed here.

Also w2app context is basically pointing to the path corresponding to a separate user in Linux. Basically in my server.xml I have a context <context path="/w2app" reloadable="true" docBase="/home/w2app/public_html" trusted="false"> </context>

Here w2app is a Linux user and I have created a public_html directory in his home directory where I am keeping some static pages.

If I go directly to the url http://a.b.c.d/w2app/test.html - the page is displayed

but if I give this link in a page on my w1app as a href - it doesn't work - due to what I explained earlier. That's why I was doing this servlet context thing.

Eventually - I want to setup the enviornment such that I create individual useraccounts (shared) ones and give them access from my w1app after successful login. I was planning that if the above scenario works then I will move the files to a WEB-INF folder under public_html .. that way people cannot get free access to those pages and I have the flexibility to give access to update those pages to respective groups.

Hope I could clarify myself.

Thanks a tonn for help

--Nihita

Steve Kirk wrote:

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]






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

Reply via email to