tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Naga Yerramsetti <n...@tems.com>
Subject Re: Servlet Collaboration
Date Mon, 12 Jun 2000 18:05:44 GMT
Sorry, I missed one line of code.

Our system is designed to have one database connection pool per protocol implementation (like
pop3,http,smtp) .(some management issues)
So Is it not advisable to have one database connection pool for all the virtual domains?
We are going ot have the classes in the CLASSPATH. I read the documentation. There  is mention
about "security conscious environment". I could not find any details explanation about this.
Is it Servlet engine dependent?

"Craig R. McClanahan" wrote:

> Naga Yerramsetti wrote:
>
> > Thanks for the response. I may not have explained well. My problem is this.
> >
> > Consider this
> >
> > Two servlets running  in different servlet contexts, ServletA in contextA and servletB
in contextB.
> > in servletA if I have
> >
> > SomeClassA objA = new SomeClassA();
> > getServleteContext().setAttribute("attribute1",objA);
> >
> > and in SevletB can I get handle  to objA using :
> >
> > SomeClassA aliasObjA = getServletContext.getContext(<<URI for SevleletA>>);
> >
>
> It would look like this:
>
>     ServletContext contextA = getServletContext().getContext("<<URI for servletA>>");
>     SomeClassA objA = (SomeClassA) contextA.getAttribute("attribute1");
>
> However, note the following issues:
>
> * The servlet container is not required to give you back a reference
>   to the other context.  In a security conscious environment, it might
>   return null -- in which case you cannot do what you are asking.
>
> * If "SomeClassA" is a class loaded from the WEB-INF/classes or
>   WEB-INF/lib directories of application A, you will get a class not
>   found or class cast exception trying to access it in application B
>   (in most servlet containers), because different class loaders are
>   used for different applications.
>
> That all being said, you are *much* better off using a database, a directory server,
shared files, or
> some other mechanism for sharing information between web applications.
>
> Craig
>
> >
> > "Craig R. McClanahan" wrote:
> >
> > > Naga Yerramsetti wrote:
> > >
> > > > Is it possible for a servlet to access servlet from another context.
> > > >
> > >
> > > What precisely do you mean by "access"?  If you mean "can I get a reference
to a servlet instance
> > > in another context", the answer is no -- you cannot even get a reference to
a servlet instance in
> > > your own context.
> > >
> > > >
> > > > We have differenet servlets running different servlet contexts(for different
virtual domains).
> > > > We need to have a management servlet that can communicate with all these
servlets
> > > >
> > >
> > > What you can do is use the java.net.URLConnection class (or it's subclass,
> > > java.net.HttpURLConnection) to make a request from one servlet to another,
and then process the
> > > response.  The details are in the JDK javadocs for these classes.  There are
also examples of
> > > using them in the Java Language Tutorial's networking trail
> > > <http://java.sun.com/docs/books/tutorial>.
> > >
> > > Craig McClanahan
> > >
> > > --------------------------------------------------------------------------
> > > To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> > > For additional commmands, email: tomcat-user-help@jakarta.apache.org


Mime
View raw message