Droplets.. are known by many names in many places viz. Dynamo Servlet Beans, ATG Servlet Beans, ATG Custom Servlets, Dynamo Servlet etc. etc... they all refer to our very own "Droplet".
What is a droplet?
A droplet is basically ATG's custom servlet which has some atg-specific customization. Just like we use HttpServlet in J2EE, we have have DynamoServlet class which implements javax.servlet.Servlet interface in ATG. (Of course there are many layers of implementation between Servlet and DynamoServlet).
Now, our DynamoServlet class has javax.servlet.Servlet in its hierarchy, therefore it becomes a servlet. There is also a layer of GenericService between Servlet and DynamoServlet to provide it with some nucleus capabilities (so that it can act as a nucleus component). Below diagram describes this:-
Therefore, to create a droplet, we extend "DynamoServlet" class, and override its "service()" method to run our custom code. Now, let us move on to create our very own "Hello World" droplet !!
How to create a droplet?
Since we are familiar with extending out of the box component, creation of droplet would be a piece of cake.
All you need to do is,
1. Create a new class and extend atg.servlet.DynamoServlet
2. Override "service()" method and write your code. This method is a starting point for your droplet, when it is invoked.
3. Create a configuration file, and set the $class nucleus property to point to your custom class created in Step#1.
How to invoke a droplet?
Let us create a JSP, and use it to invoke a droplet.
1. Create a JSP in the following location in your module:-
2. Add the <%@ taglib uri="/dspTaglib" prefix="dsp" %> on top of the jsp. This is to make your JSP aware of ATG's very own custom "dsp" tag library.
3. Invoke your droplet using <dsp:droplet> tags:-
NOTE: Try to use tags in the form <dsp:droplet></dsp:droplet> and NOT
<dsp:droplet name="..something.." />.
Sometimes ATG does not like that and your JSP is not executed correctly. See below screenshot for details:-
The JSP would produce the following output:-
Now that we know how a droplet is created and how we can invoke it, we can easily display dynamic content on our web-application!
Let us move on and understand droplets in more detail..