Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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

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

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • 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: 9615
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • 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)"
 
Marshal
Posts: 67430
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
    Bookmark Topic Watch Topic
  • New Topic