Develop > Presentation layer > Work with JSP pages
WebSphere Commerce JSP viewer
Use the JSP viewer, formerly named the JSP preview environment, to view the JSP files without its required underlying Java code. The JSP viewer allows JSP developers and Java developers to work simultaneously instead of consecutively: JSP developers do not have to wait for necessary Java code to start developing their pages.
The WebSphere Commerce JSP viewer is composed of the following components:
Web controller
The Web controller in the JSP viewer provides JSP pages with linkages to other JSP pages. Without a WebSphere Commerce environment, the HTML links in the JSP pages would not work. The Web controller mimics WebSphere Commerce run time using a XML configuration file, allowing you to see the JSP pages and simulated store flow without running any business logic. As a result, you can get an early estimation of coding effort and design problems.
useBean tag library
In the JSP viewer, the useBean tag library provides JSP pages with data that is pulled from an XML file. In the WebSphere Commerce environment, it instantiates and activates WebSphere Commerce beans, enabled using JavaServer Pages Standard Tag Library ( JSTL) technology. All JSP pages in the WebSphere Commerce starter stores use this technology.
The tag library is a wrapper to an XML parser that reads in a definition for a data bean and then re-creates that data bean with a series of lists and maps, which is then placed into the proper JSP page scope outlined by the developer. The BeanLocation.XML file provides the mapping between the bean ID and the XML file. Pages that use the same data bean end up with the same data set.
XMLGenerator
The XMLGenerator is a data bean to XML generator that is capable of creating XML files for a given WebSphere Commerce data bean.
To generate the XML file, have a populated data bean or a stubbed out data bean. The generator starts populating every method on the data bean and checks the results. This population process is done automatically when using the preview tool. In the case of a WebSphere Commerce bean (the one to be populated), set parameters. In the case of a stubbed data bean, you do not have to set parameters. The XMLGenerator also performs the following tasks:
- Bean recursion: To prevent an infinite loop from occurring, the generator keeps track of all bean objects that have been printed to the XML file and assigns them an ID. Before examining a new bean or list, the generator checks if it is a duplicate of a previous one, and if so, does not try to examine the object but instead, places a recursive attribute into the XML file. This attribute is picked up by the data bean parser at run time.
- List length: A list returned by a data bean can be very big, such as that which would come from an array, resulting in large XML files. To ensure smaller XML files, the generator has an option of imposing a maximum limit on all data types.
- commandContext or requestProperties filtering: All WebSphere Commerce data beans contain a command context or request properties object. These objects are not needed for JSP design and can increase the size of the XML file. The generator contains a flag that allows it to filter out all properties with the name commandContext and requestProperties.
- Create XML files using the XMLGenerator
Use the XMLGenerator to create XML files for the data beans.
Related concepts
WebSphere Commerce development environment
Related tasks
Create XML files using the XMLGenerator