Develop > Presentation layer > Work with JSP pages > WebSphere Commerce JSP programming best practices


JSP programming best practice: Use Commerce-specific maps to access request parameters

WebSphere Commerce provides the following Commerce-specific versions of the implicit JSP objects param and paramValues to facilitate access to decrypted HTTP request parameters:

WCParam

A Map object that maps the name of a request parameter to its single String value

WCParamValues

A Map object that maps the name of a request parameter to a String array of all values for that parameter

Although, in many cases, the standard implicit objects param and paramValues provide equivalent functionality to their Commerce-specific counterparts, the former are not guaranteed to work properly in the case of encrypted parameters, and hence WCParam and WCParamValues should be consistently used in store JSP pages.

As an example, to output the value of the catalogId request parameter, use the following statement:

<c:out value="${WCParam.catalogId}" />

Exception:

The Commerce-specific maps cannot be used to access additional parameters that are passed into a dynamically included page (that is, a page included by means of the <jsp:include> or the <c:import> tag).

Thus, in the following example, SomePage.jsp and SomeOtherPage.jsp will not be able to access showSubCategory through WCParam or WCParamValues and will have to do so through param or paramValues instead:

<jsp:include page="SomePage.jsp" flush="true">  
<jsp:param name="showSubCategory" value="true" />
</jsp:include>   ...
<c:import url="SomeOtherPage.jsp">  
<c:param name="showSubCategory" value="false" />
</c:import>

Related reference

JSP programming best practice: Use an appropriate inclusion mechanism

WebSphere Commerce JSP programming best practices


+

Search Tips   |   Advanced Search