Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In a comment I asked you to show us the code where your function <code>removeSplChars</code> was called, and to my surprise you told me that you didn't call it anywhere. Well, that answers the question why nothing has changed. If you don't call the function with the data you want to change, then nothing get changed. </p> <p>I'm trying to understand what your problem is, because it shouldn't be a problem... Then I looked closer to your code and spotted this:</p> <pre><code>'&lt;c:choose&gt;&lt;c:when test="${WCParam.source eq 'search'}"&gt;Search &lt;c:out value="${WCParam.searchTerm}" /&gt;&lt;/c:when&gt;&lt;c:otherwise&gt;&lt;c:out value="${topCat}" /&gt;|&lt;c:out value="${subCatA}" /&gt;|&lt;c:out value="${subCatB}" /&gt;|&lt;c:out value="${subCatC}" /&gt;&lt;/c:otherwise&gt;&lt;/c:choose&gt;' </code></pre> <p>You should notice that the color coding has made the word <code>search</code> in another color than the rest of the string. This is because you have started the string with a single quote and therefore the string will end at the next single quote.</p> <p>I notice that you are using JSP, which I'm not familiar with. I looked it up and saw that these tags are parsed by your server before they are sent to the client, and replaced with some text.</p> <p>Since you have problems with <em>special characters</em> like a single quote, the problem is obvious: <strong>The string that your tags output isn't escaped to be a part of a javascript string.</strong> I think your only problematic characters of all possible Unicode characters is a double quote (u+0022), single quote (u+0027) and backslash (u+005c), because they must be escaped with a backslash (like <code>\"</code>, <code>\'</code> and <code>\\</code>)</p> <p>Now, how do you do that in JSP? I don't know, but I know that you aren't the first one to have this problem. I quick search gave me <a href="http://www.coderanch.com/t/528521/JSP/java/Passing-JSTL-variable-special-characters" rel="nofollow noreferrer">this page</a> where they suggest the following:</p> <pre><code>&lt;spring:message code="${escapedString}" javaScriptEscape="true"/&gt; </code></pre> <p>Now, as I said, I'm not familiar with JSP, so I am only guessing. Try to replace all your uses of <code>&lt;c:out value="xxx"/&gt;</code> like this:</p> <pre><code>&lt;c:out value="${WCParam.searchTerm}" /&gt; </code></pre> <p>with this:</p> <pre><code>&lt;spring:message code="${WCParam.searchTerm}" javaScriptEscape="true"/&gt; </code></pre> <p>If that doesn't work look at <a href="https://stackoverflow.com/a/2110375/36866">this answer</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload