0

I have a jsp like following

            <c:forEach items="${brand.weeklyOffers}" var="weeklyOffer">
        <jsp:include page="offer.jsp">
          <jsp:param name="offer" value="${weeklyOffer}" />
        </jsp:include>
    </c:forEach>

My offer jsp looks like followig

   <c:set var="offer" value="${param.offer}"/>
   <div class="accordion-group">
<div class="accordion-heading">
    <a class="accordion-toggle collapsed" data-toggle="collapse"
        data-parent="#accordion2" href="#collapse${param.offer.offerId}"><b>${offer.header}</b></a>
</div>

throws the following exception

   Caused by: javax.el.PropertyNotFoundException: Property 'offerId' not found on type java.lang.String

but when i do

<c:out value="${param.offer}"/>

in offer.jsp than i can see the follwoing result.

 Offer [offerId=ec431f30-9c77-11e3-b3db-3c970e02b4ec, offerImages=[/offer-images/ec431f30-9c77-11e3-b3db-3c970e02b4ec/ec43e280-9c77-11e3-b3db-3c970e02b4ec.jpg], offerDescription=sasa, header=Buy 2 get 1 free, startDate=Sun Feb 16 00:00:00 CET 2014, endDate=Sat Feb 22 00:00:00 CET 2014, city=Munich, worldwide=false, iso8601StartDate=2014-02-16T00:00:00.000+01:00, prettyPrintStartDate=16 Feb, iso8601EndDate=2014-02-22T00:00:00.000+01:00, prettyPrintEndDate=22 Feb, offerType=WEEKLY] Offer [offerId=f5b8b110-9c77-11e3-b3db-3c970e02b4ec, offerImages=[], offerDescription=asas, header=asasa, startDate=Sun Feb 16 00:00:00 CET 2014, endDate=Sat Feb 22 00:00:00 CET 2014, city=, worldwide=false, iso8601StartDate=2014-02-16T00:00:00.000+01:00, prettyPrintStartDate=16 Feb, iso8601EndDate=2014-02-22T00:00:00.000+01:00, prettyPrintEndDate=22 Feb, offerType=WEEKLY]

I don't know what is the problem since the values are passed and are there.any clue..?

Saurabh Kumar
  • 16,353
  • 49
  • 133
  • 212

1 Answers1

0

jsp:param passes string parameters to the included JSP. What you're seeing is thus the result of calling toString() on your weeklyOffer bean. And this String is what is passed as parameter to the included JSP.

If you want to pass the object itself, then you can store it in a request attribute before the include:

<c:set value="${weeklyOffer}" var="offer" scope="request"/>

or transform your included JSP into a tag file accepting an offer as parameter.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255