>>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'm working on an open source framework rightnow that mirror's the ideas of
Stefano's excellent Cocoon servlet but instead keeps everything in Java by
using the above approach to dynamicially load the next class in the chain.
Imagine having a set of "templates" that just loads and executes the right
files depending on what was requested in the HTTP GET/POST arguments. Not
only that, but you can cache the result of the Class.forName line so that
you only need to do that once (even though there isn't a very large
performance penalty in Class.forName()).
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]