This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSP and the fly likes How do I set this variable in JSTL? 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 "How do I set this variable in JSTL?" Watch "How do I set this variable in JSTL?" New topic
Author

How do I set this variable in JSTL?

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Hi,

I have three page attributes (hotels, motels, rvParks) that are all lists of the same object. Based on a JSTL loop variable, I want to set a generic attribute to represent one of these three. However, this code



turns the variable accommodations into something of type string instead of the java.util.List of objects that I want. How do I adjust the above so that the variable "accommodations" gets set to the same type as the attribute I'm referring to?

Thanks, - Dave
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

Because the code is saying: "take the rendered body of the <c:set> tag and make it the value of the variable."

Rendered body will always be text.

Why aren't you handling this in the controller instead of doing hand-stands in the JSP?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Do you know how to rewrite the c:set clause to set the attribute correctly instead of the string that is getting rendered? -
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I set this variable in JSTL?