File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javascript variable inside jsp scriplet

 
Neeraj Vij
Ranch Hand
Posts: 315
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 959
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think it's possible. You can pass JSP value to javascript, but not the other way around.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Prafulla N. Patil
Ranch Hand
Posts: 106
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



in process.jsp you can get value of "javascriptvar"

getting value in that page itself is not possible
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Submitting a value to another JSP is not what the original poster was asking about.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic