• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Information from JSP to javascript  RSS feed

 
Ranch Hand
Posts: 207
2
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Right now what I have set seems hacky so I was wondering if maybe there's a better way to solve this problem other than completely changing the design.

I'm getting information that's put in by a JSP to be used in a JS map library.

I put the information I need in a hidden html tag via EL  like this:
<p hidden> ${hey.whatsup}</p>
Then I use the values how I need in JS.

Is this hacky or what?

AA
 
Author and ninkuma
Marshal
Posts: 66826
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's hacky. Why not just create real JS constructs?
 
Al Hobbs
Ranch Hand
Posts: 207
2
Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by real JS contructs? Like getting the info with a call to a rest endpoint?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66826
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. Why put the data in a fake element for JS to extract when you can just put it in the script itself?

E.g.
 
Al Hobbs
Ranch Hand
Posts: 207
2
Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oooo I see now.  Thanks!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!