Creating a servlet with ServletPathServlet and ServletPathDispatcher in ATG 9

Imagine that you want to create a servlet in ATG 9 that processes a POST request from an external website. Normal ATG Form Handlers are not of any use here because they use dynamic url parameters to be invoked. What you need is a plain old Java servlet. You can create one in ATG using two methods:

Option 1: What you would do in any other Application server without ATG

  • Create a class that extends javax.servlet.http.HttpServlet
  • Implement the doPost() and doGet() methods.
  • Add servlet mapping to web.xml

The disadvantage of the above method is that if you need access to the DynamoHttpRequest, DynamoHttpResponse objects, you need to extract them from the request using atg.servlet.ServletUtil.

public class ExampleServlet extends HttpServlet

    public doGet(HttpServletRequest request, HttpServletResponse response) {
       DynamoHttpServletRequest dRequest = ServletUtil.getDynamoRequest(request);
       DynamoHttpServletResponse dResponse= dRequest.getResponse();
   public doPost(HttpServletRequest request, HttpServletResponse response) {





Option 2: The ATG Way – Using ServletPathServlet and ServletPathDispatcher

If you are developing in ATG, chances are is that you want to do things the ATG way. Here is how you do it:

  • Create a property file for /atg/dynamo/servlet/pipeline/ServletPathServlet. Override the servletPaths property and add the path that you want the servlet to be called for (e.g. /complete-payment).
  • Create a property file for /atg/dynamo/servlet/pipeline/ServletPathDispatcher. Override the dispatcherServiceMap property and add the mapping between the path that you added in the previous step and the ATG component that you want to be called.
  • Create a class that extends DynamoServlet. Override the service(DynamoHttpServletRequest req, DynamoHttpServletResponse resp) method and place here the code that does the business logic for your servlet.
  • Restart ATG and try to access your servlet at /dyn/complete-payment. In this case dyn is the default prefix added to all servlet paths called by the ServletPathDispatcher.

# This splits the pathInfo of an incoming request into
# a servletPath/pathInfo combination, if the pathInfo
# starts with one of the servletPaths.  You can later
# dispatch off one of these paths using the
# ServletPathDispatcher component


# This dispatcher will send any requests with a
# servletPath of "/exittracking" to the ExitTracking
# component.  If you add more servletPaths here, you
# should also remember to add those paths to the
# ServletPathServlet

 * Example Servlet  
 * @author spltech
public class ExampleServlet extends DynamoServlet {
    public void service(DynamoHttpServletRequest req, DynamoHttpServletResponse res)
        throws ServletException, IOException


2 thoughts on “Creating a servlet with ServletPathServlet and ServletPathDispatcher in ATG 9”

  1. Armindo,

    Sorry to send you a note unrelated to this BLOG but I have been trying to get hold of you. We are i nthe process of creating a new application using ATG Commerce and Adobe Flex as the front-end. The client wants to use AMF/Remoting but the server side says that is not possible. Do you have any experience connecting ATG to Flex via AMF? Is that even possible? More work than it’s worth?

    Please contact me via Thank you in advance.

    Best regards,
    David LaTour
    Senior Flex Architect

  2. Hey Armindo!

    I just found that you had a blog and have been reading the ‘latest’ entries. This one is extremely interesting…. we could have applied this one in our latest project, as one of the frontend guys wanted to submit info using POST without using form handlers. In the end we told him to f*ck off and use form handlers, but if I had known this I could have provided another solution.

    Hope you are enjoying your holidays!

Leave a Reply

Your email address will not be published. Required fields are marked *