You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Saikat Chatterjee <sa...@interrait.com> on 2000/12/14 12:01:39 UTC

servlet instance

Hello All,
            I have a question regarding servlet instance.According to
the new servlet specification, is it possible to get an instance of a
servlet from another servlet?
        Earlier it was done through calling the 'getServlet(String
name)' function of the ServletContext class. But now, it has been
deprecated.

ANy help in this matter is highly appreciated

Saikat


Re: servlet instance

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Saikat Chatterjee wrote:

> Hello All,
>             I have a question regarding servlet instance.According to
> the new servlet specification, is it possible to get an instance of a
> servlet from another servlet?
>         Earlier it was done through calling the 'getServlet(String
> name)' function of the ServletContext class. But now, it has been
> deprecated.
>

It is not possible to get an instance of another servlet.  This has been true
since version 2.1 of the servlet spec, published a couple of years ago.

>
> ANy help in this matter is highly appreciated
>

Usually, people want to do this because they are using servlet instances for
something they were not designed for.  The most common case is that you are
using a servlet to contain shared utility methods, or to contain shared data.  A
better design is to consider using servlet context attributes for things that
need to be shared globally within your web application, or investigate the
Singleton design pattern and use statics.

>
> Saikat

Craig McClanahan