Simple ATG JSP and droplet

This post assumes you have installed the Commerce Reference Store. It was also written for ATG 10.0.3, although it may work on other versions, as well.

Create the following file, named printAllOrders.java, under $ATG_INSTALL_DIR/home/locallib

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import atg.servlet.*;
import atg.repository.*;

public class printAllOrders extends DynamoServlet {
  public printAllOrders() {}
  public void service (DynamoHttpServletRequest request,
                       DynamoHttpServletResponse response) 
  throws ServletException, IOException {
    try {
      MutableRepository pRepository = (MutableRepository)ServletUtil.getCurrentRequest().resolveName("/atg/commerce/order/OrderRepository");

      RepositoryItemDescriptor orderDesc = pRepository.getItemDescriptor("order");
      RepositoryView orderView = orderDesc.getRepositoryView();
      QueryBuilder orderBuilder = orderView.getQueryBuilder();
      RepositoryItem[] answer = orderView.executeQuery(orderBuilder.createUnconstrainedQuery());
      if (answer == null) {
        request.setParameter ("order_id", "No items were found");
        request.serviceParameter ("output", request, response);
      }
      else {
        for (int i=0; i

Compile it with the following command line invocations:

[atg@expressdb1 company]# cd $ATG_INSTALL_DIR 
[atg@expressdb1 ]# export CLASSPATH=.:$(pwd)/lib/classes.jar:$(pwd)/DAS/lib/servlet.jar:$(pwd)/DCS/lib/classes.jar:$(pwd)/DPS/lib/classes.jar
[atg@expressdb1 ]# javac –d ./home/locallib ./home/locallib/printAllOrders.java

Create a properties file for your component by creating a file named printAllOrders.properties under $ATG_INSTALL_DIR/home/localconfig/test. The file should have the following contents:

$class=printAllOrders
$scope=global

Copy the generated printAllOrders.class file from $ATG_INSTALL_DIR/home/locallib to $JBOSS_DIR/server/your_app_name/deploy/your_ear_file.ear/atglib/_atghome_slocallib/

Create a JSP file named $JBOSS_DIR/your_app_name/deploy/your_ear_file.ear/store.war/company/printallorders.jsp with the following contents:





Order ID’s



Restart your jboss application server with a command line similar to what is shown below:

cd $JBOSS_DIR/bin
nohup ./run.sh -c your_app_name -b 0.0.0.0 &

Navigate your browser to the base URL of your installation at the following URL (changing the jsp file name to whatever you named it above, such as printallorders.jsp).

http://your_host_name:8080/crs/company/printallorders.jsp

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.