If you want to run Servlets in your Oracle ATG Commerce application, there isn’t an easy way to expose them as Servlets AND take full advantage of the ATG component dependency and lifecycle system.

We’ve written a very simple Servlet Bridge which allows you to expose an ATG managed Servlet component as a normal Servlet via web.xml.

1. You write your Servlet class extending atg.nucleus.servlet.HttpServletService and treat it as a normal ATG component, configuring component properties, etc…. You put your Servlet logic in the service method. You configure it just like a normal ATG component.
2. You have our Sparkred ServletBridge class in your classpath.
3. You create an entry in your web.xml for each Servlet you want mapped. Each entry has a unique name, and points to the ATG component path of your Servlet class:

<servlet>
  <servlet-name>MyAwesomeServletBridge</servlet-name>
  <servlet-class>com.sparkred.ServletBridge</servlet-class>
  <init-param>
    <param-name>loggingDebug</param-name>
    <param-value>false</param-value>
  </init-param>
  <init-param>
    <param-name>destinationServlet</param-name>
    <param-value>
      ctx:dynamo:/com/myapp/servlet/AwesomeServlet
    </param-value>
  </init-param>
</servlet>
<servlet-mapping>
  <servlet-name>MyAwesomeServletBridge</servlet-name>
  <url-pattern>/servlets/awesome</url-pattern>
</servlet-mapping>

Very simple.

You can see the Sparkred ATG ServletBridge and use it in your own application.