Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can you send data from Java variables into JavaScript

 
Robert Johnson
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64844
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no

But you can write the Javascript with the data embedded.
[ April 07, 2005: Message edited by: Bear Bibeault ]
 
Kash Mhai
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can have Java variables passing values into Javascript but not other way round.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13062
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you talking about the server side, writing Javascript from inside a JSP or the client side where Javascript actually executes?
If you mean the server side - I suggest that you start with a mock-up plain HTML page containing Javascript that does what you want, then figure out how to get JSP to write that HTML.
Bill
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64844
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can have Java variables passing values into Javascript but not other way round.


No, you can't. They cannot inter-operate in any fashion. But as I stated, Java can be used to generate the Javascript that will eventually be sent to the client. That is not at all the same as "passing Java variables into Javascipt".
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As it is about "you can". Yes you can.



But you must view that resultant html file. As JSP is server-side technology and javascript is, on the other hand, client-side.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64844
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that is generating Javascript to be sent to the client. There is no "passing" in the Java sense of the term involved.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic