Boszormenyi Laszlo wrote:

> Hello!
>
>  Let's say I have some servlet, and each of them would like to reach a
> function I write into one of them. Can the others reach it somehow? Maybe
> if I restructure the code?

There are zero mechanisms in the servlet API for one servlet to gain a reference
to any other servlet instance.  Therefore, you will not be able to call a method
in one servlet from a different servlet.

>
>  I don't want to package this function to an outstanding (not tomcat -
> jakarta servlet) file.
>

You should -- that's the whole idea of object oriented design.  A servlet's job
is to accept a (usually) HTTP request, and create the corresponding response.
It's job is *not* to be a general purpose class library.

The simplest way to make objects available to all of your servlets is to store
them as servlet context attributes.

>
> Thanks,
>         Laszlo

Craig McClanahan


Reply via email to