| Author |
Javascript variable inside jsp scriplet
|
Neeraj Vij
Ranch Hand
Joined: Nov 25, 2003
Posts: 315
|
|
Hi, is there any way to pass a javascript variable value to a variable inside a scriplet in a JSP. ( this needs to be achieved without submitting the form) Thanks, Neeraj
|
 |
Freddy Wong
Ranch Hand
Joined: Sep 11, 2006
Posts: 959
|
|
|
I don't think it's possible. You can pass JSP value to javascript, but not the other way around.
|
SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
One thing that needs to be understood is that Javascript and your JSP scriptlets are interpreted at different times, on different machines. The scriptlet is interpreted on the server. It's output is the HTML and javascript that goes to the browser. The HTML is rendered, and the Javascript is interpreted in the client (browser). The scriptlet code never goes to the browser and it has already finished being interpreted at this point.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56191
|
|
Originally posted by Freddy Wong: You can pass JSP value to javascript,
No, you can't. What you can do is to use the value of JSP variables to create JavaScript that contains these values. But you can't "pass" anything. Please read this article to understand why there can be no "passing" in either direction. [ July 31, 2007: Message edited by: Bear Bibeault ]
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Prafulla N. Patil
Ranch Hand
Joined: Mar 20, 2006
Posts: 106
|
|
in process.jsp you can get value of "javascriptvar" getting value in that page itself is not possible
|
Thanks, Prafulla Patil
SCJP, SCWCD
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56191
|
|
|
Submitting a value to another JSP is not what the original poster was asking about.
|
 |
 |
|
|
subject: Javascript variable inside jsp scriplet
|
|
|