You can reroute the servlet pipeline to include your own servlets that extend the atg.servlet.pipeline.PipelineableServletImpl
class. This class implements all of the Servlet
methods, so all you need to do is override the service
method. This class defines a property called nextServlet
of type Servlet
, which specifies the next servlet in the pipeline. When your servlet finishes processing, it passes the request and response objects to the servlet specified by this property, by invoking a method called passRequest
.
The following is an example of a pipeline servlet that prints the request URI before passing the request on to the next servlet in the pipeline:
import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import atg.servlet.*; import atg.servlet.pipeline.*; public class URIPrinter extends PipelineableServletImpl { public URIPrinter () {} public void service (DynamoHttpServletRequest request, DynamoHttpServletResponse response) throws IOException, ServletException { System.out.println ("Handling request for " + request.getRequestURI ()); passRequest (request, response); } }
If you want to try out this servlet, you can insert it into the Dynamo request-handling mechanism:
Compile your servlet as
URIPrinter.java
.Create a new component as an instance of the
URIPrinter
class. For convenience, put this component in the configuration tree at/atg/dynamo/servlet/pipeline/URIPrinter
.Modify the DAF servlet pipeline to insert your
URIPrinter
between theDynamoHandler
andTransactionServlet
components. The head of the DAF servlet pipeline is the service called/atg/dynamo/servlet/pipeline/DynamoHandler
. The default value ofDynamoHandler
’snextServlet
property isTransactionServlet
, meaning that theDynamoHandler
will pass its requests to theTransactionServlet
.Change the
DynamoHandler
’snextServlet
property to point to yourURIPrinter
.Set your
URIPrinter
’snextServlet
property to theTransactionServlet
.
Now when you run Dynamo, it prints out a message for each request before the request is handled by the remaining servlets.