Integrating ATG with Adobe Flex using BlazeDS

I have had a few inquiries about whether it is possible to integrate Adobe Flex with ATG via AMF. My short answer is Yes. It should be possible. The only issue that needs to be solved though is to access the nucleus components from flex. You need a factory for that e.g. the equivalent of ejbfactory(used for EJB 3) for ATG. At some stage when I have a bit of time in my hands I will create a factory for ATG Nucleus, if nobody creates one in the mean time.

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