title: How to escape double quotes in JSTL function / EL?
body: <p>I need to change <code>"</code> to <code>\"</code> with <a href="http://download.oracle.com/javaee/5/jstl/1.1/docs/tlddocs/fn/replace.fn.html" rel="noreferrer">JSTL replace</a> function to use the string in input tag like:</p>
  
  <pre><code>&lt;input type="hidden" name="text" size="40" value="${text}"&gt;
  </code></pre>
  
  <p>If the <code>${text}</code> has the <code>"</code>, the HTML will be broken. </p>
  
  <p>So I tried</p>
  
  <pre><code>&lt;input type="hidden" name="text" size="40" value="${fn:replace(text, "\"", "\\\""}"&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>&lt;input type="hidden" name="text" size="40" value="${fn:replace(text, '"', '\"'}"&gt;
  </code></pre>
  
  <p>but didn't worked. The page makes errors like</p>
  
  <blockquote>
    <p>org.apache.el.parser.ParseException: Encountered " "}" "} "" at line
    1, column 32. Was expecting one of:
        "." ...
        ")" ...
        "[" ...
        "," ...
        ">" ...
        "gt" ...
        "&lt;" ...
        "lt" ...
        ">=" ...
        "ge" ...
        "&lt;=" ...
        "le" ...
        "==" ...
        "eq" ...
        "!=" ...
        "ne" ...
        "&amp;&amp;" ...
        "and" ...
        "||" ...
        "or" ...
        "*" ...
        "+" ...
        "-" ...
        "/" ...
        "div" ...
        "%" ...
        "mod" ...</p>
  </blockquote>
  
  <p>How can I do this?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I missed a close paren of replace function. The right one was this one with a close paren:</p>
  
  <pre><code>&lt;input type="hidden" name="text" size="40" value="${fn:replace(text, '"', '\"')}"&gt;
  </code></pre>
  
  <p><strong>Update2</strong></p>
  
  <p>I found out that when posting texts, using <code>\</code> is not a good idea because of this reason <a href="https://stackoverflow.com/questions/3634069/why-cant-use-in-html-input-tag">why can&#39;t use \&quot; in HTML input tag?</a>. The code should be like this:</p>
  
  <pre><code>&lt;input type="hidden" name="text" size="40" value="${fn:replace(text, '"', '&amp;quot;')}"&gt;
  </code></pre>