Julie Langstrump
Julie Langstrump

Reputation: 897

How to set value from<security:authentication/> to the parameter with <c:set>

I have a problem in my jsp page. I use Spring security and I need to get a name of the authentificated user, for this I use the next tag

 <security:authentication property="name" />

I need to compare this value with other String, how can I do this? I thought I can set this value to some parameter like

<c:set var="userName" value="<security:authentication property='name'/>"scope="page" />

and then to compare my values

<c:when test="${(params.userSelect.login eq pageScope.userName)}">

but this doesn't work. I get the name from <security:authentication property="name" /> (I can view it on jsp page), but I can't compare this values.

Upvotes: 2

Views: 1536

Answers (1)

Rontologist
Rontologist

Reputation: 3558

c:set can take the content of the body in as the value.

<c:set var="userName"><security:authentication property="name" /></c:set>

Upvotes: 4

Related Questions