• 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

EL - Problem rendering String with quote

 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following works fine as long as the names do not have a quote. For example, a name such as O'brien causes an error when the JSP is rendered. Is there a function that will help to encode or handle this situation?

Thanks!

<td>${member.lastName}</td>
<td>${member.firstName}</td>
 
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
What kind of error?
 
Bosun Bello
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's actually a JavaScript error because I am building variables to be passed into a javascript methjod when the option button is selected. But I am thinking it's because EL is not handling the quote correctly.

The following also causes an error ONLY if the names contain a quote.


<c:set <c:set var="mInfo" value="'${status.count}','${member.firstName}','${member.lastName}', '${member.sex}', '${member.relationshipCode}'" />


The actual Javascript error is - Error expected ')'

I guess the quote in the name is throwing it off to make it thinks it's the end of a string.
[ August 16, 2007: Message edited by: Bosun Bello ]
 
Bear Bibeault
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
Well, yeah. Your JSP is just going to create a page to send to the browser. If that page contains badly formatted JavaScript, the browser will complain no matter how the page was generated.

When you're going to emit text that will be embedded in a JavaScript string, you need to make sure that any quotes (of either type) are properly escaped.
reply
    Bookmark Topic Watch Topic
  • New Topic