Develop > Presentation layer > Work with JSP pages > WebSphere Commerce JSP programming best practices
JSP programming best practice: Use the Commerce-specific tag for bean activation
WebSphere Commerce data beans require activation prior to their use. WebSphere Commerce provides a Commerce-specific version of the useBean tag, <wcbase:useBean>, that performs data bean activation in Java-free manner and is the recommended method of data bean activation in store JSP pages.
As an example, the generic way of activating a category data bean is...
<jsp:useBean id="categoryBean" class="com.ibm.commerce.catalog.beans.CategoryDataBean"> <% com.ibm.commerce.beans.DataBeanManager.activate(categoryBean, request, response); %> </jsp:useBean>
The recommended way of accomplishing the same task in WebSphere Commerce store pages is...
<wcbase:useBean id="categoryBean" classname="com.ibm.commerce.catalog.beans.CategoryDataBean" />
Data bean activation can fail and cause an exceptional condition.
To comply with the JavaServer Pages Specification requirement that no output be written to the output stream when forwarding to other Web assets, including error pages, data beans should be activated at the beginning of the JSP page.
Related concepts
WebSphere Commerce useBean tag
WebSphere Commerce framework overview
Related reference
JSP programming best practice: Use JSTL in place of Java code
WebSphere Commerce JSP programming best practices