aspose file tools*
The moose likes JSP and the fly likes Can you send data from Java variables into JavaScript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Can you send data from Java variables into JavaScript" Watch "Can you send data from Java variables into JavaScript" New topic
Author

Can you send data from Java variables into JavaScript

Robert Johnson
Ranch Hand

Joined: Feb 11, 2005
Posts: 32
?


Whats in a name?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61232
    
  66

no

But you can write the Javascript with the data embedded.
[ April 07, 2005: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Kash Mhai
Greenhorn

Joined: Apr 01, 2005
Posts: 29
You can have Java variables passing values into Javascript but not other way round.


-------------<br />There are wheels within wheels...<br />P.G Wodehouse
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12789
    
    5
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

Joined: Jan 10, 2002
Posts: 61232
    
  66

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

Joined: Aug 15, 2004
Posts: 2874
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

Joined: Jan 10, 2002
Posts: 61232
    
  66

Yes, that is generating Javascript to be sent to the client. There is no "passing" in the Java sense of the term involved.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can you send data from Java variables into JavaScript