This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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 ...
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Can ot read values from JSP iun JavaScript

Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following is Javascriptfragment

Below is JSP fragment setting this value

When I am running this code, in the alert I am getting alert messsage as
hi <%= alternateLocaleDCR %>

Why is expression not getting evaluated in this JS code ? Why am I not getting value of hasLocale variable set as "yes" ?
Please let me know, whats wrong here ?

Posts: 1845
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's wrong here?

Apart from your use of scriptlets?

Remember the order that things run in.

Java/JSP runs, and produces an HTML page.
Javascript starts running when the HTML page reaches your browser.

I would suggest you do a view source on this page to take a look at what the JSP has generated for the javascript to execute.

Where does the javascript fragment get evaluated in relation to the JSP fragment?

The outcome you are seeing seems to indicate that the JSP interpreter is not run on your javascript fragment. Is that javascript fragment in a JSP file or something else?
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!