On Fri, 30 Apr 1999, Joshua Slack wrote:
> I am working on a servlet that interprets a template. Based on the
> template's contents, the servlet needs to call other servlets and plug
> in the appropriate data.
>
> For example, if the template had some line:
> menu choices=2 choice1=front choice2=back
>
> This would tell the interpreting servlet to call some servlet called
> "menu" and pass it the values "choices=2 choice1=front choice2=back".
> The "menu" servlet would then return some resulting data to the
> interpreting servlet which the interpreting servlet could then send
> back to the client.
>From your example here, I can't see why you would want your secondary
classes to be servlets at all. Sounds like what you really want is to have
some helper classes conform to an API of your choosing that you can plug
them in as desired. Something like this:
public interface ServletHelper {
public void init(ConnectionPool pool, Object otherparameter);
public String process(Hashtable table);
}
You can have your helper classes implement this interface and use the
process method to pass data to and from the helpers. You could either
manually instantiate your helper classes in your servlet code or, if
you've got a lot of them, you can use apache's classloader to load them at
runtime. There are lots of good tricks you can employ using this approach.
> Writing individual servlets to get data from databases and files,
> manipulate content, and so forth has been quite easy, but the question
> is, how can I call a servlet from inside another servlet and pass it
> variables? Programming sources are pretty vague on this, most of them
> referring to servlet chaining which I believe is not implemented in
> Jserv.
IMHO, there's no need to bastardize the servlet paradigm to manage
interclass communication.
- donald
----------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
READ THE FAQ!!!! <http://java.apache.org/faq/>
Archives and Other: <http://java.apache.org/main/mail.html/>
Problems?: [EMAIL PROTECTED]