Desaretiuss
Desaretiuss

Reputation: 311

Accessing session's attribute from jsp fails

Actually, when I use scriplets: <%= session.getAttribute("loginId") %> the value is printed on page . The problem arises when I use Expression Language, then it doesn't show anything.

<td>LoginId: </td>
<td><input type="text" value="${loginId}" /></td>

Upvotes: 1

Views: 59

Answers (2)

Desaretiuss
Desaretiuss

Reputation: 311

Finally I found the solution to this problem. The correct syntax to use when accessing session attributes in struts2 is:

<s:property value="#session['key']"/>

Source

Upvotes: 1

SatyaTNV
SatyaTNV

Reputation: 4135

Use

<s:property value="#session.loginId"/>

or

${session.loginId}

to display session scoped variable value.

Upvotes: 1

Related Questions