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:-
<ATG_MODULE>/j2ee-apps/<YOUR_APP_NAME>/<YOUR_WAR_FILE_NAME>.war/helloWorld.jsp
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:-
<dsp:droplet name="{YOUR_DROPLET_COMPONENT_PATH}">
</dsp:droplet>
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..
can you please share your email id ?
ReplyDeleteYou can post your questions here and i'll be glad to answer them.
DeleteHi Monis, I tried the same steps as given here to create a droplet. The output of my JSP is in plain text and not HTML. Infact the HTML tags also show up in the browser.
ReplyDeleteHi Jaya,
DeleteYou can try adding
pResponse.setContentType("text/html");
in your droplet. This will render HTML on your page instead of plain-text.
And the same thing happens with my form handler? Any thoughts?
ReplyDeleteThe basic component-class structure is same, but a formhandler is different in many ways.
DeleteYou can have a look at the article HERE (ART#113): http://learnoracleatg.blogspot.in/2014/11/art113-how-to-usecreate-formhandlers-in.html
Hi monis, I'm getting
ReplyDeleteError 500--Internal Server Error
javax.servlet.jsp.JspException: CANT_FIND_DROPLET: Unable to find the droplet with name "/atg/hello/HelloWorldComponent". I have done same as above.
Can you help y this is happening.
This means that your component is not getting resolved.
DeleteMake sure that the HelloWorldComponent.properties is present in the config-path inside the folders /atg/hello
hi Monis,
ReplyDeletecan you please explain what exactly is the difference between component and droplet
A droplet is a special type of component.
DeleteThe class you use in a droplet's component must extend DynamoHttpServlet.
In a normal component (non-droplet), you can have any class.
Deletehi Monis,
ReplyDeletecan you please explain the difference between droplet and component.
a Droplet is a special type of component which extends DynamoServlet and is generally used for display logic.
DeleteThis is very helpful.
ReplyDeleteThanks :)
DeleteHi Monish
ReplyDeleteDo we need to map the droplet in web.xml?
No, we don't need to do that.
Delete