You can pass parameters to an ATG servlet bean just as you do to an embedded JSP. For example, the following passes the storename parameter with a value of Joe's Hardware to the ATG servlet bean /test/DSBStoreTest:

<%@ 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()returns 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.


Copyright © 1997, 2016 Oracle and/or its affiliates. All rights reserved. Legal Notices