Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing the expression language in javascript of a jsp page

Tags:

javascript

jsp

el

I have a "jsp" file. In that file I have "Javascript" scripting. Within <script> tags,only javascript is allowed but, how is "Expression Language" executed?

<body>
    <script type="text/javascript">
        var b=${requestScope.name};
    </script>
</body>
like image 772
reddy Avatar asked Oct 11 '13 12:10

reddy


3 Answers

bring that variable from request scope to page scope,

<c:set var="myVar" value="${request.myVar}" />

after this you can try this :

<script>
    var myVar= '${myVar}' ;
</script>

Though I am not sure if it's the best approach; but this should do.

like image 50
uneakharsh Avatar answered Oct 13 '22 01:10

uneakharsh


Executed.

As "Expression Language" is executed on the server side the statement

${requestScope.name} 

executed at server side and its value is available to JavaScript at client side. now at the client side the line becomes

var b='corresponding expression language executed value';
like image 34
seedi Avatar answered Oct 12 '22 23:10

seedi


JSP is server side. You cannot access the script variables. These variables are only executed client-side.

like image 39
R. Oosterholt Avatar answered Oct 13 '22 01:10

R. Oosterholt