Ben Cleora wrote:
> --- "Craig R. McClanahan" <[EMAIL PROTECTED]>
> wrote:
> > particular user can hold a number of simultaneous
> > active sessions to
> > different applications. If those apps run in
> > different servlet contexts
> > on the same virtual host, it is up to the server
> > configuration to make
> > sure there are no problems with this.
>
> Is there a standard way for the different applications
> (with different ServletContexts and HttpSessions) to
> share information under this model?
>
> Thanks.
>
> - Ben
>
Within the standard (again, we're talking about 2.1 or 2.2 here), there
is an optional mechanism that the servlet engine can support. The
ServletContext.getContext() call can be used to get a reference to
another ServletContext (the one that would be used to process the URI
you specify as an argument), and therefore you would gain access to its
attributes (and RequestDispatchers, for that matter). However, this
will probably be disabled in a security conscious environment, because
it might grant inadvertent access to things like pre-logged-in
connection pools that are stored in the cotnext attributes.
Outside the servlet API spec itself, there are several approaches you
can use to share information (these apply to both servlet-based and
non-servlet-based Java apps, for that matter):
* Use a shared class with static accessor methods (be sure
you load this class from the system class path, and not
the context-specific class path, to avoid class loader issues).
This works as long as your app runs entirely within a
single JVM.
* Attach both contexts to the same back-end persistent data
store (commonly shared files, databases, etc.) and pass information
back and forth through that.
* Use remote Java-based services (through RMI, CORBA/IIOP,
JINI, or EJBs) to implement the information sharing.
Which of these is best, of course, is application specific. I've used
all three for various purposes.
Craig
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
READ THE FAQ!!!! <http://java.apache.org/faq/>
Archives and Other: <http://java.apache.org/main/mail.html/>
Problems?: [EMAIL PROTECTED]