File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes JSP, JavaBean Coding with JavaScript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP, JavaBean Coding with JavaScript" Watch "JSP, JavaBean Coding with JavaScript" New topic
Author

JSP, JavaBean Coding with JavaScript

peanut
Greenhorn

Joined: Jan 07, 2002
Posts: 4
Is there a way whereby the values of JSP variables be assigned to the JavaScript variables and vice versa?
Mani Balasubramanian
Greenhorn

Joined: Jan 03, 2002
Posts: 15
Have you tried this
Jsp variable in javascript:
<script language="javascript">
var javascriptVar = "<%=jspVar%>";
</script>
The otherway round is not possibile directly. Either you have to pass the javascript variable as a url to another jsp page or submit the page to another jsp page with javascript variable as a hidden field.
peanut
Greenhorn

Joined: Jan 07, 2002
Posts: 4
i have tried the example u gave me but it will give me syntax error when i run it.
Angela Poynton
Ranch Hand

Joined: Mar 02, 2000
Posts: 3143
When you tried it did you assign a value to jspVar??

You might want to print out javascriptVar in the Javascript too!!


Pounding at a thick stone wall won't move it, sometimes, you need to step back to see the way around.
peanut
Greenhorn

Joined: Jan 07, 2002
Posts: 4
i did assign the values to the JSP variable n assign to JavaScript variable but it will give me error - syntax error.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"peanut",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp .
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please re-register with a new name which meets the requirements.
Thanks.
Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP, JavaBean Coding with JavaScript
 
Similar Threads
md5 jsp javascript
Head First Servlets & JSP book - JSP Question
JSP & JavaScript! assigning values to html form through Session variable
JSP with JavaScript
Sharing of variables