The previous section mentioned that, although it is possible to pass open parameters to ATG servlet beans, those parameters should not be read with the standard getParameter()
method. In fact, it is unlikely that your ATG servlet bean wants to see the actual value of an open parameter. In most situations, an ATG servlet bean wants to output the value of an open parameter. To do this, use the serviceParameter
method of the request, as in the following example:
import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import atg.servlet.*; public class DSBTest2 extends DynamoServlet { public DSBTest2 () {} public void service (DynamoHttpServletRequest request, DynamoHttpServletResponse response) throws ServletException, IOException { ServletOutputStream out = response.getOutputStream (); out.println ("Here's the value of the parameter 'storename':"); request.serviceParameter ("storename", request, response); } }
The serviceParameter
method obtains the value of the given parameter and displays it.
To demonstrate this, save the previous code sample as DSBTest2.java
and compile it into a class file and create a corresponding Nucleus component in much the same way as you did in Simple ATG Servlet Bean Example. Create dsbtest2.jsp
with the following contents:
<%@ taglib uri="/dspTaglib" prefix="dsp" %> <dsp:page> <html> <head> <title>Storename Test</title> </head> <body bgcolor="#ffffff"> <h1>Storename Test</h1> <dsp:droplet name="/test/DSBTest2"> <dsp:oparam name="storename"> <h1>Joe's Hardware</h1> </dsp:oparam> </dsp:droplet> </body> </html> </dsp:page>
Preview this page to see how it looks when processed and compiled.
The serviceParameter
prints out any parameter including simple Strings and open parameters. If an open parameter includes dynamic elements such as dsp:valueof
and dsp:droplet
tags, those elements are also generated dynamically.
The serviceParameter
method returns a Boolean value indicating whether the specified parameter was found or not (true
if the parameter was found).