File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes JavaScript var inside JSP Scriptlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JavaScript var inside JSP Scriptlets" Watch "JavaScript var inside JSP Scriptlets" New topic

JavaScript var inside JSP Scriptlets

Chua Keng Guan

Joined: Oct 11, 2006
Posts: 10
<script type="text/JavaScript">

var a = 1;
<% JavaFile.staticInt = a %>


The above example will cause a error stated that varible a is not found(no such symbol). Do anyone know how to solve this problem. Thanks
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

JSP is server side script, so you won't access Javascript variables. Try to figure out another way to get the needed data.

[My Blog]
All roads lead to JavaRanch
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63548

You have a fundamental misunderstanding of what JSP technology is all about.

Perhaps this article will be helpful.
[ October 17, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: JavaScript var inside JSP Scriptlets
It's not a secret anymore!