Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL: key field includes a period (.)  RSS feed

 
Terry Martinson
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having problems changing the following <bean define> tag to the JSTL <c:set>

<bean define id="foo" type="xxx.yyy.SomeClass" scope="session" name="prefix.suffix"/>

My attempt at the <c:set>:
<c:set var="foo" value="sessionScope[authorization.token]" />

My variable foo is not getting out there correctly. It's out there, but is of type String rather than the hoped for type of "SomeClass".

The key for the session variable includes a period, and I think this is what's causing me the problem. I have attempted to escape it out, but that didn't work. I also attempted to use the other [] syntax and that also didn't work.

Is it possible to use a key that includes a dot?

p.s. In my actual JSP file, I do have a colon in between the "bean" and "define", but I'm having problems getting this post to display properly with the colon in there.

Thanks.

TJ

[ August 02, 2004: Message edited by: Terry Martinson ]

[ August 02, 2004: Message edited by: Terry Martinson ]

[ August 02, 2004: Message edited by: Terry Martinson ]
[ August 02, 2004: Message edited by: Terry Martinson ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To begin with I would avoid properties and scoped variable names with embedded periods if at all possible.

If it's beyond your control, then (as you know) you need to use the [] dereferencing mechanism. But like in Javascript, this mechanism expects the property name as a string. So the correct notation would be:

 
Terry Martinson
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this case it is beyond my control. I got it to work as you suggested, with my final syntax being:

<c:set var="foo" value="${sessionScope['authorization.token']}" />

Thanks alot!

TJ
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!