tags:

views:

21

answers:

2

Hi ,

I set the session variable like below

getSession(true).setAttribute("entriesCount", "10");

then the call below returning nothing in jstl.

<c:out value="${#session.entriesCount}"/>
+3  A: 

Try

<c:out value="${entriesCount}"/>

or

<c:out value="${sessionScope.entriesCount}"/>

This seems useful:

the expression ${name} refers to a scoped variable named name. That scoped variable can reside in page, request, session, or application scope. The expression language searches those scopes, in that order, for scoped variables.

and

The implicit objects listed above let you explicitly access variables stored in a specific scope; for example, if you know that the name scoped variable resides in session scope, the expression ${sessionScope.name} is equivalent to ${name}, but the latter unnecessarily searches the page and request scopes before finding the name scoped variable in session scope

Bozho
+1  A: 

Where did you read about #session and what's it? You should be fine just with <c:out value="${entriesCount}"/>.

Nikita Rybak