Danny Trieu wrote:

> why not?.... if you define your bean's scope to be application, then you can access
> from other application.

This is not necessarily correct in all circumstances.

JSP's scope=application is the same as servlets storing attributes in the servlet
context of your *own* application.  Thus, attributes for other web applications are
not stored there.

However, ServletContext has a getContext() method that can return the ServletContext
object for a different web application (based on the path you specify).  You can use
getAttribute() on the context object that is returned to access the application
resources of that other application.

But (there's always a but) ... the servlet container has the right to disable
getContext() -- by making it return null -- in security conscious environments.  You
may also run into class cast issues if the servlet contexts are run under different
class loaders  Check the documentation on your servlet container to know for sure what
goes on there.

None of this is going to help you, though, access sessions (and the associated user
data) across web applications -- sessions are unique to a particular servlet context
and are not sharable.  You will need to use some additional mechanism (besides
servlet-supported sessions) to share per-user information across applications.

>  But i don't how it's gonna scale if one or more of your
> apps
> runs on and different machine or different virtual host.
>

Multi-JVM distributed environments (either on the same server or multiple servers)
varies so widely that it is pretty hard to generalize.  Check the docs for your server
platform to know for sure.

Craig McClanahan


>
> Leo Fu wrote:
>
> > Hi,
> >
> > The design of my project consists of several web-applications (as
> > defined in section 1.5 of the JSP1.0 spec). One application provides the
> > functionality of user authentication and the other are the applications
> > which the user can execute after login. The problem is from one
> > application it can't obtain the user session object created by the User
> > Authentication application (req.getSession() returns null). Am I missing
> > anything here? Seems like the "resources" among web applications can't
> > be shared. Is there any work around?
> >
> > Thanks in advance.
> >
> > -Leo
> >
> > ===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> > FAQs on JSP can be found at:
> >  http://java.sun.com/products/jsp/faq.html
> >  http://www.esperanto.org.nz/jsp/jspfaq.html
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> FAQs on JSP can be found at:
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to