Two Laptop Bag*
The moose likes JSP and the fly likes Setting an object with c:set from sessionScope Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Setting an object with c:set from sessionScope" Watch "Setting an object with c:set from sessionScope" New topic
Author

Setting an object with c:set from sessionScope

Sverre Moe
Ranch Hand

Joined: Jul 10, 2007
Posts: 110
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

Joined: Jan 10, 2002
Posts: 61082
    
  66

items="List1"


Carefully examine this attribute. Is it doing what you think it is?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sverre Moe
Ranch Hand

Joined: Jul 10, 2007
Posts: 110
I must be getting alsheimer... ${List1} it should be....
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61082
    
  66

Sometimes it just takes somebody leaning over your shoulder...

I call it the "what's that semi-colon doing there?" syndrome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting an object with c:set from sessionScope