Creating and registering new storefront JavaServer Pages files

To create and register a new JavaServer Pages (JSP) files to display in the storefront, you must decide where to put the file in your store directory structure, create it, and register it in the Struts configuration file.

Procedure

  1. To create the JavaServer Pages (JSP) file:
    1. In the Enterprise Explorer view, expand Stores > WebContent > StoreName.
    2. Optional: Choose or create a folder to contain the new JSP file. For example, you may want to make a new folder under the ShoppingArea folder to contain your JSP file.
    3. Right-click the folder where you want the new JSP file; then select New > JSP File.
    4. In the File name field, enter a name for the new JSP file and click Finish. The newly created file automatically opens.
    5. You are now ready to develop the code for your JSP file. However, you may want to continue with the rest of this task, and register the file with HCL Commerce before proceeding with coding. This allows you to develop the page in iterations, and see the results in the store.
  2. Register your new JSP files in the Struts configuration file:

    Any new JSP files must be registered in the Struts config file to be recognized by HCL Commerce. Modifying the Struts configuration associates a new view with the actual JSP file.

    1. Determine your store ID, if you do not already know it. If you do not know your store ID, run the following SQL query to determine the ID:
      select * from storeent;
    2. In the Enterprise Explorer view, expand Stores > Struts > <default module>.
    3. Open the Struts configuration file.
      • Stores > WebContent > WEB-INF > struts-config-ext.xml
      • HCL Commerce Version 9.0.1.0 or laterStores > src > struts-wcs-stores-custom.xml
    4. Add a forward or result entry in the custom struts configuration file.
      • Add a <forward> entry in the global forward section, which is found at the beginning of the file. For example:
        <forward className="com.ibm.commerce.struts.ECActionForward" name="RecipeSection/10001" path="/ShoppingArea/RecipeSection/RecipeSection.jsp"/>
        
      • HCL Commerce Version 9.0.1.0 or laterAdd a <result> entry in the global forward section, which is found at the beginning of the file. For example:
        <result name="RecipeSection/10001" type="wcsredirect"> /ShoppingArea/RecipeSection/RecipeSection.jsp<result>

      The name is the name of your JSP file without the extension, concatenated with / and your store ID. For example, RecipeSection.jsp in store ID 10001 would be registered as name="RecipeSection/10001".

      The path is the relative path to your new file, from the following location in your development environment: Stores > WebContent > StoreName.

    5. e. Add an <action> entry in custom struts configuration file.
      • In the action mappings section, which is found at the end of the file, replace RecipeSection with the name of your JSP file, without the file extension

        Replace the value 10001 with your own store ID.

        <action path="/RecipeSection" type="com.ibm.commerce.struts.BaseAction">
        <set-property property="https" value="10001:1"/>
        </action>
        
      • HCL Commerce Version 9.0.1.0 or laterAdd an action to the Struts package which is found at the end of the file. Continuing our example, replace RecipeSection with the name of your JSP file, without the file extension.
        <action name="RecipeSection" class="com.ibm.commerce.struts.v2.BaseAction">
          <param name="https">10001:1</param>
        </action>
      Note: For extended sites, use the storeent_id of the Asset Store to which these JSP files are registered. Individual extended sites stores inherit these commands from the asset store because created stores have no JSP files of their own.
  3. Create access control policies for the new JSP file.

    By default, only site administrators can access new views. Create access control policies for each new JSP file to allow general access.

    1. Create a file called JSPNameCommand.xml under the directory workspace_dir\WC\xml\policies\xml.
    2. Paste the following into the JSPNameCommand.xml file, and save it.

      In the following example, JSPName is RecipeSection, as in our other examples.

      <?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?>
      <!DOCTYPE Policies SYSTEM "../dtd/accesscontrolpolicies.dtd">
      
      <Policies>
      
      <Action Name="RecipeSection" CommandName="RecipeSection">
      </Action>
      <ActionGroup Name="AllSiteUsersViews" OwnerID="RootOrganization">
      <ActionGroupAction Name="RecipeSection"/>
      </ActionGroup>
      
      </Policies>
      
    3. At the command prompt, navigate to WCDE_installdir\bin.
    4. Run the following command:
      DB2
      acpload db_name db_user
       db_password JSPNameCommand.xml db_schema