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


Reply via email to