Access in what respect? If you want to do redirects, then that's pretty easy so I'm not going to answer that. If you're talking about sharing context data, I've only had luck with the technique at the bottom. First I'll explain why you can't directly access resources in another context.
If you have a servlet in a 'myapp1' context (i.e. http://localhost/myapp1/servlet/Controller
) and it tries to do something like this:
// and similarly, .include(request, response);
then it'll probably throw an exception or will report that it cannot find the file. The parameter of getRequestDispatcher is automatically appended to the calling servlet's context path (i.e. so in this case, it will try to forward the request to: http://localhost/myapp1/myapp2/process.jsp
) which is probably not what you wanted.
Sharing of attributes stored in the servlet context is possible:
ServletContext sc = getServletConfig().getServletContext().getContext("/mycontext");
One you have a ServletContext object, you can set and get attributes (objects).
Hope this helps somewhat.