Extract information from response properties to display on JSP pages

In this lesson, you learn how to modify the MyNewControllerCmdImpl to pass information to the JSP page. You modify the command to add additional name-value pairs into the existing rspProp TypedProperties object that stores response properties from the command. Within the JSP page, you use the JavaServer Tag Library (JSTL) expression language to extract the information from the response properties.


  1. Modify the MyNewControllerCmdImpl class.
    1. In the Enterprise Explorer view , expand WebSphereCommerceServerExtensionsLogic > src > com.ibm.commerce.sample.commands.
    2. Open the MyNewControllerCmdImpl.java file for editing.
    3. In the Outline view, select the performExecute method.
    4. Locate and uncomment section 2 to add the code that stores two parameters in the response properties object which will be passed to the view:
      /// Section 2 ////////////////////////////////////////////////>
          /// The controller command passes variables to the JSP page>
        /// add additional parameters in controller command to rspProp 
        ///  for response
          String message1 = "Hello from IBM!";
        rspProp.put("controllerParm1", message1);
        rspProp.put("controllerParm2", "Have a nice day!");>
      /// End of section 2/////////////////////////////////////////
    5. Save your changes.
  2. Update the MyNewJSPTemplate.jsp file:
    1. In the Enterprise Explorer view , expand Stores > WebContent > Madisons.
    2. Right-click the MyNewJSPTemplate_All.jsp file; select Open With > Page Designer.
    3. Right-click the MyNewJSPTemplate.jsp file; select Open With > Page Designer.
    4. In the MyNewJSPTemplate_All.jsp file, locate and copy section 4; paste the copied section into the MyNewJSPTemplate.jsp file between the <!-- SECTION 4 --> and <!-- END OF SECTION 4 --> markers. This section uses the JSTL expression language to retrieve and display the values that were passed from the controller command.
    5. In the MyNewJSPTemplate.jsp file, section 4 should resemble:
      <!-- SECTION 4 -->
      <fmt:message key="ParametersFromCmd" bundle="${tutorial}" />
      <fmt:message key="ControllerParm1" bundle="${tutorial}" />
      <c:out value="${controllerParm1}"/>
       <br />
      <fmt:message key="ControllerParm2" bundle="${tutorial}" />
      <c:out value="${controllerParm2}"/>
       <br />
       <br />
      <!-- END OF SECTION 4 -->
      This section uses
    6. Save your changes.
  3. Test the modifications to the controller command and the JSP page:
    1. Start or restart the WebSphere Commerce test server.
    2. Expand Stores > WebContent > Madisons.
    3. Right-click the index.jsp file; click Run As > Run on Server. Your storefront page displays in the web browser.
      Note: If prompted to select a server, select Choose an existing server and click Finish.
    4. In the web browser, enter the following URL: http://localhost/webapp/wcs/stores/servlet/MyNewControllerCmd
      The new JSP page displays in the web browser:
      Screen capture of JSP page with parameter value pairs from controller command