wood burning stoves 2.0*
The moose likes Servlets and the fly likes variable to javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "variable to javascript" Watch "variable to javascript" New topic
Author

variable to javascript

Nauman Khan
Ranch Hand

Joined: Aug 07, 2003
Posts: 49
Hi,

I am simply producing an html page with javascrpt from Servlet and passing a variable to javascript

String name="hello";
alert("alert("+name+");");
As I know about Servlet is server site and javascript is client side but if it doesn't work and get the error, Does anybody know if i have to pass the value from Servlet to javascript then what is the other way to do it?

Regards,


Nauman Khan <br />SCJP,MCSE,SCWCD,SCBCD,SCWCD1.4
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Since JavaScript is just text, you simply write the desired value with the rest of the text. You will have to pay attention to escaping the quote marks.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: variable to javascript
 
Similar Threads
not able to get uploaded file size in javascript
Javascript function trying to access Scriptlet value
passing javascript array from jsp to servlet
jQuery and JSF - NEWBIE question
Problem in JavaScript equals comparison for Strings