AndreFontaine
AndreFontaine

Reputation: 2584

Java set string value with JSTL c tag

I'm trying to set a String value from session. I want something like that:

<%
    String getReactive = <c:out value="${result}"></c:out>;
%>

I know it not gonna works. But I need something similar to this:

<%
    String getReactive =  ics.GetVar("result");
%>

Upvotes: 1

Views: 11478

Answers (1)

Master Slave
Master Slave

Reputation: 28549

There's a c:set attribute available

<c:set var="getReactive" value="${result}"  />

you can also set scope attribute and define the scope of the variable you set. Accessing the variable further down would be simply by

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

the other way around is to use the implicit session object so simply

<%
    String getReactive =  (String) session.getAttribute("result");
%>

Upvotes: 5

Related Questions