guillaume ORIOL wrote:

> Jason hunter, in his book Java Servlet Programming, explains how to access one
> servlet from
> another one, using the ServletContext.getServlet() and Servlet.getServlet()
> methods.
>

This method is deprecated in the 2.1 and 2.2 servlet APIs, and will always return
null.  Thus, the method that Jason describes in his book is no longer useful in
current servlet engines.  Any existing code that depends on it should be
rewritten.

There is no longer any way through the servlet API for *any* application class to
get a reference to *any* servlet.

>
> In my case, I have a class (not a servlet one) that wants to access the
> methods of one
> servlet. Is there a static method that gives a reference to a ServletContext
> object,
> or any other mean ?
>

There is no such static method.  Even if there was, you would not be able to
accomplish your goal because getServlet() is deprecated.

You should remove the method you are trying to call from its containing servlet,
and put it in some other Java class.  Then, make that new class available as a
context attribute or session attribute (depending on whether it is shared
globally or not).

>
> thanks in advance
> guillaume ORIOL
>

Craig McClanahan

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to