Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Intialize javascript variable using jsp

 
tony al
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am experiencing the following problem in my JSP page which uses javascript;
I need to intialize a javascript variable as follows:
rootFld = F("class").I("1.1").I("1.2")._(F("1.3").I("1.3.1").I("1.3.2"))._(F("1.4").I("1.4.1"))._(F("1.5").I("1.5.2")) ;
This variable represents a dynamic tree structure that is to be displayed on the webpage.
I need to initialize the above variable from a variable in java scriptlet. As you can see the variable is not a string and I am not sure how to initiaze it using a java variable.
Any help is much appreciated
thanks
 
Chris Reeves
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your jsp, set a String to the value you wish to assign to the javascript variable:
String jsVar = "whatever";
Then, set the javascript variable in the output:
 
Ronald Francis
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Watch out ...the double quotes in your example could cause some pain ..
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't post teh same question in more than one forum. You obviously read more than one forum, so do the people who might answer your question.
There are more answers to this question in this other thread, but I have closed it and referred readers to this one.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic