• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can I use JSP to put info into Javascript?

 
Toni Howlett
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will this work?

I plan to use JSP to pull some values from my properties file, and I want to populate an array with those values.

So could I have JSP in my <script> tags?
(In my mind, this will work - but before I go spending time doing it and it doesn't work I was just going to ask. I know that JSP runs first and only once)
 
Paul Clapham
Sheriff
Posts: 21862
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, you could have JSP code inside a <script> element. But as you already know, that JSP will be evaluated before the browser even sees the <script> element. So just make sure your JSP code generates a Javascript assignment statement which assigns an array to a variable.
 
Toni Howlett
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alrightie - Awesome!! Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might find this article helpful in understand how JSP operates in this regard.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!