tags:

views:

3216

answers:

1

Hello friends,

Is it possible to access struts2 variable in jsp scriptlet?

If I have struts2 variable like

<s:set var="test" value="%{'true'}"/>

Can I use variable "test" in JSP scriptlet?

If yes. How is it possible?

Can anyone give some idea about it?

Thanks.

A: 
<jsp:useBean id="test" class="java.lang.String" scope="request"/>

<%
         test = "false";
%>

1. outside scriptlet: <c:out value="${test}"/>   <!-- will not print anything -->

<%
    out.println("2. in scriptlet: " + test);     // will print false
%>

<c:set var="test" value="true" />

3. outside scriptlet: <c:out value="${test}"/>   <!-- will print true -->

<%
    out.println("4. in scriptlet: " + test);     // will print false
%>
Green Techy