An application typically contains embedded HTML and JSP files, which often rely on exchanging parameters. For example, two bicycle shops under the same ownership—Spinning Wheel and Power Wheel—run on the same site. The pages for each store use a header whose format and functionality are virtually identical, except for some customized content that identifies the individual store. In order to share the same header file, the JSP for each store calls the header file with dsp:include
, which passes a parameter that identifies the given store.
For example, the applicable code for the Spinning Wheel site’s JSP looks like this:
<dsp:include page=header.jsp>
<dsp:param name="storename" value="Spinning Wheel"/>
</dsp:include>
The code for the sister store Power Wheel looks like this:
<dsp:include page=header.jsp>
<dsp:param name="storename" value="Power Wheel"/>
</dsp:include>
At runtime, the dsp:include
tag passes in storename
as a page parameter to header.jsp
. This parameter is available to DSP tags in the header file, as in the following example:
<h1>Welcome to <dsp:valueof param="storename"/></h1>
At runtime, the valueof
tag’s param
attribute resolves to the value supplied by the parent page—Spinning Wheel or Power Wheel—and displays in the included page header accordingly.