Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to pass a JavaScript variable into a java method

843836Aug 4 2003 — edited Aug 4 2003
I would like to know how to pass a JavaScript variable into a java method with in a <% %> tag inside a JSP file like so:


<%@ page contentType="text/html;charset=windows-1252"%>

<html>

<head>
<script LANGUAGE="JavaScript">

myValue = someDynamicValue;

<% System.out.println(myValue)%>


</script>
</head>
<body>
</body>
</html>

obviously "System.out.println(myValue)" will not work because myValue is seen as a java variable and not a JavaScript variable.
I would like to know how to let the jsp file, that I wrote in the above code, see myValue as a JavaScript variable and not a java variable so that I can pass it to a java method.

NOTE: the java method does not have to be a println() method, it can be any method of my choice.

NOTE: someDynamicValue is a JavaScript value that can dynamically change
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 1 2003
Added on Aug 4 2003
1 comment
469 views