Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
anjanayya myathri
Greenhorn
Posts: 3
Java Spring Tomcat Server
  • 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(<cut value='${iter.value1} />' , '<cut value='${iter.value2}' /> ', <cut 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
Java Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
view source has been disabled on the page. any other suggestions...?
 
bala nannaka
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
Java Spring Tomcat Server
  • 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
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic