Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting an object with c:set from sessionScope

 
Sverre Moe
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Through sessionScope I have an object SessionData in which has a Customer object within.

I create a variable customer by the following c:set
<c:set value="${sessionScope.sessionData.customer}" var="customer"></c:set>
This one work perfectly. I am able to access the getters in customer, ${customer.name}

Then I try to create List1 from an object within the customer object(AnObject) of java.util.List
<c:set value="${customer.anObject.aList}" var="List1"></c:set>

When I try to iterate this list I get an error
<c:forEach items="List1" var="agr">
${agr.aNumber }
</c:forEach>


Unable to find a value for "aNumber" in object of class "java.lang.String" using operator "."


When I try to access the List1.getSize() with ${List1.size} I get the following error.


The "." operator was supplied with an index value of type "java.lang.String" to be applied to a List or array, but that value cannot be converted to an integer.


I am trying to create pure JSP and JSTL instead of struts logic
<bean:define id="sessionBean" name="sessionData" scope="session" />
<bean:define id="customer" name="sessionBean" property="customer" type="Customer" />
<bean:define id="List1" name="customer" property="anObject.aList" type="java.util.List" />
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
items="List1"


Carefully examine this attribute. Is it doing what you think it is?
 
Sverre Moe
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I must be getting alsheimer... ${List1} it should be....
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sometimes it just takes somebody leaning over your shoulder...

I call it the "what's that semi-colon doing there?" syndrome.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic