0

My string is a HTML code which contains single quotation and I want replace this with a escape and a single quotation.

Example
Input: <p style='padding-left:30px;'>
Output: <p style=\'padding-left:30px;'>

I try this and tried escape single quotation (like '\'' but doesn't works):

<c:set var="htmlEvento" value="${fn:replace(filial.eventos, ''', '\\'')}"/>

Error

Caused by: org.apache.jasper.JasperException: /loja/FilialLojaList.jsp (line: 125, column: 11) "${fn:replace(filial.eventos, ''', '\'')}" contains invalid expression(s): javax.el.ELException: Failed to parse the expression [${fn:replace(filial.eventos, ''', '\'')}]

Daniela Morais
  • 2,125
  • 7
  • 28
  • 49
  • Possible duplicate of [How to use both single and double quotes inside JSTL/EL expression?](http://stackoverflow.com/questions/8898815/how-to-use-both-single-and-double-quotes-inside-jstl-el-expression) This is not per say a duplicate, but this is close enough and the solution would be the same ;) – AxelH Mar 09 '17 at 14:10

1 Answers1

0
<c:set var="input" value="<p style='padding-left:30px;'>"></c:set>

<c:set var="output" value="${fn:replace(input, '\\'', '\\\\\\'')}"/>
Input: <c:out value="${input }"></c:out> </br>
Output: <c:out value="${ output}"></c:out>

Output:

Input: <p style='padding-left:30px;'> 
Output:<p style=\'padding-left:30px;\'>
Neha Shettar
  • 703
  • 10
  • 28