On Wed, 8 Sep 1999, Lance Lavandowska wrote:
> That isn't strictly true. You can call the [static/class] methods
> of another servlet (though it's not recommended). Just import the
> servlet as you would any class (this is the tricky part), then call
> the static method as you would normally. This approach won't likely
> work with instance methods.
I think the real questions here are why this person wants to do this
and what are they really trying to do. More often than not when I see
questions like this it seems that the best answer is a
redesign/reorganization of the classes (like taking the desired
functionality out of the other servlet and putting it into a class
that both servlets can use).
> -----Original Message-----
> From: Nic Ferrier <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> Date: Wednesday, September 08, 1999 6:06 AM
> Subject: Re: how to call other servlet's method
>
> >>>> Lomesh Contractor <[EMAIL PROTECTED]> 9/8/99 10:37:55 AM >>>
> >> I want to know how can i call other servlet's method ?
> >
> >If you mean:
> >"how can one servlet call a method in another servlet?"
> >
> >You can't. Servlets can only communicate with each other through the
> >servlet engine.
> >See below.
> >(you could if the method was public static but that's not what you
> >mean I suspect).
> >
> >
> >If you mean:
> >"how can one servlet call another?"
> >
> >You can use a RequestDispatcher or a URL.
> >
> >eg with RequestDispatcher:
> >
> > //some code in a servlet
> > RequestDispatcher
> >rd=getContext().getRequestDispatcher("/2ndservletpath");
> > rd.forward(request,response);
> >
> >
> >Hope this helps but I'm not exactly sure what you mean.
> >
>
Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
[EMAIL PROTECTED]
___________________________________________________________________________
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