Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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 ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Javascript error "Expected ')' " on rendering the page.

 
Greenhorn
Posts: 3
Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, am getting an js error due to break of the page while rendering the page.

Am getting error at below statement
<input type="radio" name="something" value="something1" onclick="method1(<c:out value='${iter.value1} />' , '<c:out value='${iter.value2}' /> ', <c:out value='${iter.value3}'/> );"

In second parameter if the value has apostrophe character, then we are getting the error.
Am not able to escape it as it is written in the tags:
can you please help me out here.
 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is JSP source. What we need to see is the rendered HTML at the browser. Do a View Source to see what's been sent to the browser.
 
anjanayya myathri
Greenhorn
Posts: 3
Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
view source has been disabled on the page. any other suggestions...?
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All the latest browsers are equipped with developer friendly tools. just click f12 and verify in the console.you can test and modify the js code from your console try it
 
anjanayya myathri
Greenhorn
Posts: 3
Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its a pop-up window with special previleges, so they have disabled almost all the functionalities for it.
Is ter any replacement for <c: out value="${iter.description}"/> statement. ?
 
bala nannaka
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you need to escape the html characters from serverside so that apostrophe will not break the js
 
author & internet detective
Posts: 40035
809
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OWASP provides an Encoder API where you can escape for various languages including JavaScript.
 
What's brown and sticky? ... a stick. Or a tiny ad.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic