0

I have tried this many a times but unable to do this. first let me put my code. ::

<script type="text/javascript">
function delemp(v){
    alert(v);
    <%
    String abc=%>v<%;

    %>
out.println(abc);
}

</script>
<script type="text/javascript">
$(document).ready(function(){
var h= "Shantanu";
delemp(h);
});
</script>

In the above code. I am calling delemp(h);. That should assign value "Shantanu" to variable abc. and then print that value. But i am unable to do this. when i comment the scriptlet part and run only alert(v) it gives me value Shantanu that is value is passing to function delemp(v). But unable to assign it to abc. It gives me an error ::

Type Mismatch: cannot convert from Void to string.

Where's the prob? thanks..

2
  • Java is not my language but I would have thought this get compiled before any call to the JS function so it's not possible to assign value in Java from JS Commented Apr 13, 2012 at 7:28
  • @gillesc I need to use js variable v in java code(scriptlets).. Is there anything i can do. ? Any way out... I have gt this link .. See the answer over here.. Whats the difference between this and my ques. stackoverflow.com/questions/9923702/… Commented Apr 13, 2012 at 8:41

1 Answer 1

1

You cannot do this. The scriptlets are executed on server before the page would be loaded, but javascript - on client. When you execute your js, you're already have the result of evaluating of the scriptlets and it couldn't be changed with js.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.