• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Intialize javascript variable using jsp

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Watch out ...the double quotes in your example could cause some pain ..
 
Sheriff
Posts: 6999
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
if you think brussel sprouts are yummy, you should try any other food. And this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic