The following DSP tags let you pass parameters to the page that they invoke:

You can pass parameters to the target page by embedding one or more dsp:param tags between the open and close tags. For example, you might set the dsp.a tag to create an anchor tag that passes a user’s city as a query parameter:

<dsp:a href="homepage.jsp">Go to your home page
     <dsp:param name="city" beanvalue="Profile.homeAddress.city"/>
</dsp:a>

When a user clicks on this hyperlink, the tag resolves to a hyperlink string that embeds the parameter city as a query string. For example:

<a href="homepage.jsp?city=Boston"></a>

When the target page homepage.jsp is invoked by this hyperlink, it can access city as a page parameter. In the following example, the page tests this parameter with the JSTL tag c:choose:

<c:choose>
   <c:when test="${param.city ==  Boston}">
      A new store is coming soon near you!
   </c:when>

   <c:when test="${param.city == Atlanta}">
       There's a sale at your local store!
   </c:when>

   <c:when test="${param.city == Seattle}">
       The local store is going out of business. Visit the clearance sale.
   </c:when>

   <c:otherwise>
        Check our new products! Now you can purchase more products from the
        Web site.
   </c:otherwise>
</c:choose>

The query string city is held as an attribute of the param implicit object and referenced as param.city. Other operations that involve obtaining content from the request or response objects follow a similar format.

Click here to learn about our other stores:
<dsp:a href="${pageContext.request.requestURI}"?city= atlanta>Atlanta</dsp:a>
<dsp:a href="${pageContext.request.requestURI}"?city= boston>Boston</dsp:a>

In this example, when the user clicks the boston link, the current page reloads only this time it contains the query parameter boston so the page reflects information about the Boston location.

Note: Tags that invoke other pages like dsp:a and dsp:include can pass component property values to the target page; however, they cannot pass the component itself. In the previous example, the anchor tag passes the value of the JavaBean property Game.score to results.jsp; in order to obtain the component Game, the page must explicitly import it with dsp:import.


Copyright © 1997, 2012 Oracle and/or its affiliates. All rights reserved.

Legal Notices