<% if(empRecNum != null && !(empRecNum.equals("")))
{
empSelected=true;
}
boolean canModify = UTIL.hasSecurity("PFTMODFY") && empSelected;
%>
<script type="text/javascript">
function add(){
alert(canModify);
df('ADD');
}
</script>
I need to alert the canModify in my JavaScript
<% if(empRecNum != null && !(empRecNum.equals("")))
{
empSelected=true;
}
boolean canModify = UTIL.hasSecurity("PFTMODFY") && empSelected;
%>
<script type="text/javascript">
function add(){
alert(canModify);
df('ADD');
}
</script>
I need to alert the canModify in my JavaScript
Share Improve this question edited Oct 25, 2010 at 14:10 Jigar Joshi 241k42 gold badges409 silver badges446 bronze badges asked Oct 25, 2010 at 14:06 JohnJohn 1,1893 gold badges19 silver badges29 bronze badges3 Answers
Reset to default 3I know I use something like this:
<%
String s = "BOB";
%>
<script>
alert('<%= s %>');
</script>
The '<%= %>' tag lets you put in the value of the java variable.
Get away from using scriptlets, use jstl and expression language and it would look like this:
alert( ${UTIL.hasSecurity("PFTMODFY")
&& empRecNum != null
&& !(empRecNum.equals("")
}
);
Do some thing like.
function add(){
alert(<%=canModify%>);
df('ADD');
}