One problem with out-of-the-box chaining is that a servlet is expecting an
http request and is sending an http response. Chaining requires that the
first servlet's response be somehow transformed into an httprequest again. A
servlet meant to operate as other than the first element in a chain has to
operate differently than a 'normal' servlet anyway - it must pass or modify
headers properly, it must recognize that its input stream is really a
response etc. Hence Jon's proposal is a sensible direction in that it avoids
creating portmanteau servlets.
> I agree that this could be done elegantly without requiring the use of a
> directive in the conf. files. But the issue I was addressing was
> out-of-the-box use of servlets which could be available as
> components... in
> this case, it would be beneficial to be able to chain them in some optimal
> way without having to write code...
>
> rajesh
>
> > >>There are better ways to chain servlets...it is called
> > >Class.forName().
> > >
> > > How??? Could you elaborate on this??
> >
> > some semi-pseudo code to get you into the picture...the idea
> > being that you
> > can dynamicially execute another "servlet" that implements
> > the ServletChain
> > interface.
> >
> > public interface ServletChain
> > {
> > public void execute (HttpServletOutputStream output);
> > }
> >
> > ServletChain chain = null;
> >
> > String servletToExecuteNext = "myservlet";
> > Class aClass = Class.forName ( servletToExecuteNext );
> > chain = (ServletChain) aClass.newInstance();
> > chain.execute( output )
> >
> >
> > I have been using a framework like this for 2+ years now and
> > it is the most
> > flexible way to do things. I have one main "servlet" that
> > simply loads and
> > executes classes that implement the various interfaces. This
> > has benefits of
> > things like a single point to throw exceptions to as well as
> > a single entry
> > point for security control. It is also very easy for multiple
> > developers to
> > work on portions of the same project at the same time because
> > all they have
> > to do is work on a single "module" that implements the well defined
> > interface.
> >
> > > How would it handle chaining servlets as in a piped
> > chain... I think that
> > > the ability to pipe output between servlets is a pretty
> > good feature...
> >
> > It is good to chain servlets, but not as a piped chain. This
> > is something
> > that is extremely confusing to users and is very limiting in
> > that all you
> > can modify is the output of the previous servlet. Why not use
> > the above
> > approach to extend the "ServletChain" interface and make things more
> > scalable and dynamic?
> >
> > -jon
----------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html/>
Problems?: [EMAIL PROTECTED]