user1950540
user1950540

Reputation: 61

How to access a variable in struts if tag?

Using the code below

<%! int role; >

<%
   UserMasterDTO userMasterDTO=(UserMasterDTO)session.getAttribute("userMasterDTO"); 
   role = userMasterDTO.getRole();
%>

I want to get this value read by my struts if tag. How to achieve this?
Is below code not the correct way?

<s:if test="role == 1">

Upvotes: 1

Views: 3534

Answers (1)

imxylz
imxylz

Reputation: 7937

Try struts 2.x 'if' tag:

<s:if test="#session.userMasterDTO.role==1">

or

<s:set name='role' value=xxxx>

Never using java code in jsp/template is a good habit.

Upvotes: 4

Related Questions