• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem using jstl in javascript

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, in my jsp page I have:


And in my javascript function:


And it doesn't takes the index in ${}, but if I use alert(index) it recognize it. What is wrong?
Thanks in advanced
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand. What did you mean to happen, and what actually happened?

Let me remind you that the JSP (including JSTL) runs on the server and generates HTML, which may include Javascript. You didn't say whether this Javascript code was generated by the JSP or not. Then later, after that is all finished, the Javascript may run in the browser, on the client. You can't expect JSTL to do anything at this point.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As the code contains Struts tags, this has been moved to the Struts forum. Please be sure to post any questions containing Struts artifacts to that forum.
 
Bradusca Luisa
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:I don't understand. What did you mean to happen, and what actually happened?

Let me remind you that the JSP (including JSTL) runs on the server and generates HTML, which may include Javascript. You didn't say whether this Javascript code was generated by the JSP or not. Then later, after that is all finished, the Javascript may run in the browser, on the client. You can't expect JSTL to do anything at this point.



Hi Paul, thanks for your reply!
Yes, the javascript code was generated by the JSP, and now I understant why ${} couldn't see my index variable because el is executed at server side and javascript at client side.
But how I can do what I meant to do that is: user selects a bean from a select option and I want to appear information about that bean in a div/span..-wich is:name,address,email and so on.(I allready have all the list generated in server side and also I have an index property so that I can choose easier listOfBeans.get(index).)
Thanks in advanced!
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You either need to use Ajax, or build up all the JavaScript you need on the server side.
 
Please enjoy this holographic presentation of our apocalyptic dilemma right after this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic