This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to access a javascript variable from Java?  RSS feed

 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my code:



...but how do I access the javascript variable 'username' from the Java code?

Thanks,
James
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65825
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't. The Java code in your JSP (very old-fashioned that, putting Java in a JSP) executes on the server long before the page gets to the browser where the JavaScript can be interpreted.

Please read this article in order to understand the life cycle of a JSP.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Posts: 12086
246
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James,

Please check your private messages for an important administrative matter.

Thanks, Andrew
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!