views:

361

answers:

2

I have the following code to set a userId variable:

(userId set in prior code)

<c:set var="userId" value="(Cust#${userId})" />

Which produces the following string: (Cust#${userId})

The following code works as expected, however:

<c:set var="userId" value="(Cust# ${userId})" />

displays the following string (Cust# 0001) .

Why does the '#' character before a '${string}' expression prevent the string from being evaluated? Is there a work around I could use that doesnt involve having to insert a space?

+2  A: 

Since JSF would use:

#{userId}

To return a user Id, I would venture to guess that this is either a bug or expected behavior caused by the # sign making the parser unhappy. Just use either of:

<c:set var="userId" value="(Cust&#35;${userId})" />
<c:set var="userId" >(Cust&#35;${userId})</c:set>
stevedbrown
thank you for the information + suggestion.
tehblanx
I think £ represents the currency symbol '£'. # would be the Unicode entity '#'.
McDowell
Yeah, definitely correct (I edited my answer)
stevedbrown
A: 

I tested the above and it does not work. Its ouput would be:

Cust#0002 or whatever.

You can use an escape to get it to work right though. For example:

<c:set var="userId" value="(Cust\#${userId})" />

The output is:

Cust#0002

Dale Larsen