Lasa
Lasa

Reputation: 31

ATG servlet and Droplet

I'm new for the ATG framework and I want to know different between Servlet and droplet in ATG. I read some tutorials , but still haven't clear idea.

Upvotes: 0

Views: 911

Answers (2)

tfarooqi
tfarooqi

Reputation: 69

When you say only Servlet, then that is a generic Java software component that provides a functionality based on a request it receives. A Java servlet needs to run in a servlet container.

Specific to ATG, there are two kinds of components that are termed as servlets - DynamoServlet and PipelineableServlet.

A DynamoServlet is the base class you need to extend to create a Droplet. A Droplet is basically a piece of Java code that you can run on a JSP page running within an ATG application. It is included on a JSP page using the tag that ATG provides. When a JSP executes, it will execute the code within the Droplet and present the output of the Droplet on the page.

A PipelineableServlet is a class (which is part of a chain of classes called a Servlet Pipeline) that provides a functionality when an HTTP request is received. Each servlet in the chain performs a specific operation on the request and relays the modified request to the next servlet in the chain.

Upvotes: 0

Michael Guinn
Michael Guinn

Reputation: 117

I haven't worked with ATG in a few years, and you may be working with a different version than I did, but a simple way to answer this would be to say that Servlets are more of a J2EE MVC concept, the controller in that case, while Droplets are ATG's "controller". ATG's design patterns aren't exactly MVC (there tends to be quite a bit more logic in the view in most cases), but droplets are meant to be reusable components that the view (your JSPs) use to get data from the model (your xxxManager, xxxService, Repository layer classes, etc.)

For example, if I'm working on a page that is meant to display the shopping cart, I might register a "/Cart" servlet in my web.xml in J2EE. When a doGet is invoked on this servlet, I would call all of the model components I need to gather data about the cart, and use the RequestDispatcher to send that data to a JSP. All of my model/controller logic is done here, and then sent to be rendered by the view.

In ATG, you tend to rely less on web.xml configurations and more on components registered and instantiated by Nucleus. So you might create your cart.jsp and use tags like to grab the data you need ad hoc. You might have a droplet to calculate the current price and display it, or to get promotions applied to the profile and list them. Each piece of data you need for the page, you could use a droplet tag to gather and display.

You might say that droplets tend to be "on page" while servlets are meant to be "between pages."

Upvotes: 2

Related Questions