On Fri, 11 Jan 2002, Brandon Cruz wrote:

> Date: Fri, 11 Jan 2002 18:07:00 -0600
> From: Brandon Cruz <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: Tomcat Users List <[EMAIL PROTECTED]>
> Subject: RE: Sessions across contexts, is it possible?
>
> This seems to be breaking the jsp specification.  Will this really work, and
> will it bring headaches in the future if I switch to a different servlet
> container?
>

Containers are not required to let you call ServletContext.getContext()
and get a non-null value -- it is allowed to return null for all requests
(for security reasons).  For Tomcat 4, the default is to disallow this
kind of access, but you can turn it off (with the crossContext attribute).
Other servers may or may not let you enable this facility.

Even if you get the reference to the other ServletContext, I would be more
concerned about your reliance on getRealPath() at all -- which implies
that you are going to use file I/O to retrieve static resources from
within the "other" webapp.  This won't work at all when the application is
*not* run from an unpacked directory -- you should use
ServletContext.getResource() or ServletContext.getResourceAsStream()
instead for maximum portability.

Craig


--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to