• 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

Display Struts Application Resource Property with apostrophe in JSP with javascript alert

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am using Struts 1.2 .I have a jsp page where in I need to display an javascript alert message by retreiving the message key value from Application Resources properties file as soon as the page is displayed.
The message property has single quote (') in the value.I used '','\',"\'",’ to display single quote but I am unable to display the '.

The message key and value in the properties file is :

display.clientnotfound.msg = Client's account data not found.

I jsp,I am displaying the alert as
<script>
alert('<bean:message key= "display.clientnotfound.msg" />')
</script>

Can anyone suggest me on how I can display property value with ' using javascript alert message.


Thanks in Advance,
Siva
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since it is probably the browser that is interpreting the single quote as ending the alert message, you can't use Java code escape characters (i.e. \' ).
Try using an HTML entity to replace the apostrophe:

Hmm. It looks like the code tags are eating my HTML entity. Click here and scroll down to "Html Entity (named)"
 
Sheriff
Posts: 67747
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
I took the liberty of fixing Joe's code block.
 
siva sankar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Ess wrote:Since it is probably the browser that is interpreting the single quote as ending the alert message, you can't use Java code escape characters (i.e. \' ).
Try using an HTML entity to replace the apostrophe:

Hmm. It looks like the code tags are eating my HTML entity. Click here and scroll down to "Html Entity (named)"




Thanks Joe. But even after using ’ it is not working. is there any other special code to be used to achieve this?
 
I am Arthur, King of the Britons. And this is a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic