Develop > Presentation layer > Work with JSP pages


Create and registering new storefront JavaServer Pages files

To create and register a new JSPs files to display in the storefront, decide where to put the file in the store directory structure, create it, and register it in the Struts configuration file.


Procedure

  1. To create the JSPs 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 the 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 the JSP file. However, you may want to continue with the rest of this task, and register the file with WebSphere Commerce before proceeding with coding. This allows you to develop the page in iterations, and see the results in the store.

  2. Register the new JSP files in the Struts configuration file:

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

    1. Determine the store ID, if you do not already know it. If you do not know the 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-config-ext.xml file.

    4. 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"/>

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

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

    5. Add an <action> entry in the action mappings section, which is found at the end of the file. Continuing our example, replace RecipeSection with the name of the JSP file, without the file extension.

      Replace the value 10001 with the own store ID.

      <action path="/RecipeSection" type="com.ibm.commerce.struts.BaseAction">
      <set-property property="https" value="10001:1"/>
      </action>
      

  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. Stop the WebSphere Commerce server, if it is running.

    2. Create a file called JSPNameCommand.xml under the directory WC_EAR\xml\policies\xml.

    3. 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>
      

    4. At the command prompt, navigate to WCDE_INSTALL\bin.

    5. Run the following command:

      • acpload JSPNameCommand.xml

      • acpload db_name db_user db_password JSPNameCommand.xml db_schema


+

Search Tips   |   Advanced Search