Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JSTL functions, replace a single quotue by two single quote

843840Jul 17 2009 — edited Jul 18 2009
Hi,

In a JSP :
<script type="text/javascript">
 function showAlert(value)
 {
	 alert(value);
 }
</script>

<input type="button" onclick="showValue('${requestScope.myvalue}');"/>
I have a problem if ${requestScope.myvalue} return a value with a single quote. For exmple, hello'hello
I need to scape the single quote in hello'hello to hello'\hello because is a argument of a javascript function.
I am trying it with the replace funtion
${fn:replace(requestScope.myvalue,'\'','\\\'')}
But don't work. I need to replace the single quote ' by '\
Do you know how can i get it with the replace function ?

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 15 2009
Added on Jul 17 2009
5 comments
2,390 views