The following is a simple example of using an ATG Servlet Bean to produce JSP code within a page.

Create the following ATG Servlet Bean in a file named DSBTest.java and save it to <ATG2007.3dir>/home/locallib:

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

public class DSBTest extends DynamoServlet {
  public DSBTest () {}
  public void service (DynamoHttpServletRequest request,
                       DynamoHttpServletResponse response)
       throws ServletException, IOException
  {
    ServletOutputStream out = response.getOutputStream ();
    out.println ("<h1>I am generated by a java object.</h1>");
  }
}

Define <ATG2007.3dir>/DAS/lib/classes.jar in your CLASSPATH, and compile DSBTest.class. Create an instance of it as a Nucleus component:

Now you can access the component from a JSP. In the J2EE Pages task area, create a new JavaServer Page named dsbtest.jsp in a running application. For example, if you are running the ATG Adaptive Scenario Engine, save this file in the QuincyFunds application.

Add this text to dsbtest.jsp:

<%@ taglib uri="/dspTaglib" prefix="dsp" %>
<dsp:page>

<html>
<head>
  <title>DSBtest</title>
</head>

<body>
<h1>DSB Test </h1>

<p>From a java object:

<p>Did it work?

</body>
</html>

</dsp:page>

Now embed the DSBTest servlet bean:

Notice how this example uses the dsp:droplet tag. When you embed an ATG Servlet Bean, you use a name attribute that specifies the name of the Nucleus component to embed. Nucleus finds the component, makes sure that it implements Servlet, then hands the request to the component to satisfy the dsp:droplet tag.

To make the /test/DSBTest component visible in the Dynamic Element Editor, you can use the dsp:importbean tag to import the component into the scope of your page.

 
loading table of contents...