First read the following:
- What is a Droplet? - http://learnoracleatg.blogspot.com/2014/10/art109-what-are-droplets-or-dynamo.html
- How to pass parameters to a Droplet from JSP? http://learnoracleatg.blogspot.in/2014/10/art110-how-to-pass-parameters-to.html
Here is what I did:
Step 1: I created a HelloWorldDroplet in modules.base
/modules.base/src/atg/repository/HelloWorldDroplet.java
package atg.repository; import java.io.IOException; import javax.servlet.ServletException; import atg.servlet.DynamoHttpServletRequest; import atg.servlet.DynamoHttpServletResponse; import atg.servlet.DynamoServlet; public class HelloWorldDroplet extends DynamoServlet { public void service(DynamoHttpServletRequest request, DynamoHttpServletResponse response) throws IOException, ServletException{ String myInput = request.getParameter("input"); response.setContentType("text/html"); myInput = myInput.concat(" appended from droplet"); request.setParameter("concatenatedString", myInput); request.serviceParameter("CUSTOMOUTPUT", request, response); response.getOutputStream().println("Hello World\n"); } }
Step 2: A droplet is a component. So we need to create a configuration file. Here is the HelloWorldComponent.properties
Step 3: How to invoke a droplet from JSP?
/modules.store/j2ee-apps/Web/Web.war/hello/helloworld.jsp
/modules.store/j2ee-apps/Web/Web.war/hello/helloworld.jsp
<%@ taglib uri="/dspTaglib" prefix="dsp"%> <dsp:page> <dsp:importbean bean="/atg/hello/HelloWorldComponent" /> <html> <body> Here is the text from droplet<br> <dsp:droplet name="HelloWorldComponent"> <dsp:param name="input" value="passed from jsp" /> <dsp:oparam name="CUSTOMOUTPUT"> <dsp:valueof param="concatenatedString" /> </dsp:oparam> </dsp:droplet> </body> </html> </dsp:page>
<context-param> <param-name>context-root</param-name> <param-value>sams</param-value> </context-param>
More about Droplets: Out Of the box droplets:
- I tried out how to use "ForEach" droplet. Here is what I did:
Step 1: Create an employee component i.e a java file and a properties file.
package atg.repository; /** * * * @version : 1.0 */ import java.util.ArrayList; import java.util.List; public class EmployeeBean { List<String> carsList = new ArrayList<String>(); public List<String> getCarsList() { return carsList; } public void setCarsList(List<String> carsList) { this.carsList = carsList; } }
$class=atg.repository.EmployeeBean carsList=\ Honda,\ Skoda,\ Mercedes,\ VW
Step 2: Write the JSP which invokes the droplet:
<%@ taglib uri="/dspTaglib" prefix="dsp"%> <dsp:page> <dsp:droplet name="/atg/dynamo/droplet/ForEach"> <dsp:param name ="array" bean="/atg/hello/EmployeeComponent.carsList" /> <dsp:oparam name="outputStart"> <p> The employee has following cars: <br/></p> </dsp:oparam> <ul> <dsp:oparam name = "output"> <li><dsp:valueof param="element"></dsp:valueof></li> </dsp:oparam> </ul> <dsp:oparam name ="outputEnd"> Thats all! </dsp:oparam> </dsp:droplet> </dsp:page>
Step 3: To access this JSP type, http://localhost:8080/myapp/hello/helloemployee.jsp in the browser and see the output as following:

