You can pass parameters to an ATG Servlet Bean just as you would to an embedded JSP. For example, the following passes the storename parameter with a value of “Joe’s Hardware” to the /test/DSBStoreTest ATG Servlet Bean:

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

<html>
<head><title>DSB Store Test</title></head>
<body><h1>DSB Store Test</h1>

<dsp:droplet name="/test/DSBStoreTest">
  <dsp:param name="storename" value="Joe's Hardware"/>
</dsp:droplet>

</body></html>

</dsp:page>

You can access these parameters with the getParameter() call found in HttpServletRequest, as in the following ATG Servlet Bean, DSBStoreTest.java, which prints out a header that includes the storename parameter:

public void service (DynamoHttpServletRequest request,
                     DynamoHttpServletResponse response)
     throws ServletException, IOException
{
  String storename = request.getParameter ("storename");
  if (storename == null) storename = "No-Name's";

  ServletOutputStream out = response.getOutputStream ();
  out.println ("<h1>Welcome to " + storename + "</h1>");
}

If the parameter is not defined, getParameter() will return null, so your code should be prepared for that situation.

Your ATG Servlet Bean can access any parameter that is visible to the dsp:droplet tag calling the ATG Servlet Bean. This includes parameters passed directly to the ATG Servlet Bean, as well as any parameters visible to the JSP containing the dsp:droplet tag.

Because getParameter() can return only Strings, this method should be used only for parameters that are not open parameters. The next sections describe a more general way to deal with parameters, both simple and open.

 
loading table of contents...