• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

variable to javascript

 
Nauman Khan
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic