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>
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>
Share
Improve this question
edited Nov 27, 2013 at 13:19
BalusC
1.1m376 gold badges3.6k silver badges3.6k bronze badges
asked Oct 11, 2013 at 12:55
reddyreddy
6752 gold badges9 silver badges19 bronze badges
1
- you can check this detailed answer. stackoverflow./a/39355888/1577363 – erhun Commented Sep 6, 2016 at 18:47
3 Answers
Reset to default 5bring 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.
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 bees
var b='corresponding expression language executed value';
JSP is server side. You cannot access the script variables. These variables are only executed client-side.