Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Answer: Solved the same by following the below mentioned steps.</p> <ol> <li><p>Retained the following section </p> <pre><code>&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; </code></pre></li> </ol> <p>in the head section of the JSP. Have removed the &lt; tag before the meta tag .</p> <ol start="2"> <li><p>Added the UTF-8 enforcer in my Web.xml. Following piece of code was used.</p> <pre><code>&lt;filter&gt; &lt;filter-name&gt;encodingFilter/filter-name&gt; &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter/filter-class&gt; &lt;init-param&gt; &lt;param-name&gt;encoding/param-name&gt; &lt;param-value&gt;UTF-8/param-value&gt; &lt;/init-param&gt; &lt;init-param&gt; &lt;param-name&gt;forceEncoding/param-name&gt; &lt;param-value&gt;true/param-value&gt; &lt;/init-param&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;encodingFilter/filter-name&gt; &lt;url-pattern&gt;/*/url-pattern&gt; &lt;/filter-mapping&gt; </code></pre></li> <li><p>Made used of a utility to convert the smart quotes to plain text. The utility I used is stated below (Took reference from <a href="http://forum.springsource.org/showthread.php?72944-How-to-handle-Smart-Quotes-pasted-into-TextArea-input" rel="nofollow">http://forum.springsource.org/showthread.php?72944-How-to-handle-Smart-Quotes-pasted-into-TextArea-input</a>). Thanks to RobertGloverJr for posting that part of the solution.</p> <pre><code>public static void windows1252ToIso8859(StringBuilder sbOriginal) { if (null==sbOriginal) { return; } for (int isb = 0; isb &lt; sbOriginal.length(); isb++) { int origCharAsInt = (int) sbOriginal.charAt(isb); switch (origCharAsInt) { case ((int)'\u2018'): sbOriginal.setCharAt(isb, '\''); break; // left single quote case ((int)'\u2019'): sbOriginal.setCharAt(isb, '\''); break; // right single quote case ((int)'\u201A'): sbOriginal.setCharAt(isb, '\''); break; // lower quotation mark case ((int)'\u201C'): sbOriginal.setCharAt(isb, '"'); break; // left double quote case ((int)'\u201D'): sbOriginal.setCharAt(isb, '"'); break; // right double quote case ((int)'\u201E'): sbOriginal.setCharAt(isb, '"'); break; // double low quotation mark case ((int)'\u2039'): sbOriginal.setCharAt(isb, '\''); break; // Single Left-Pointing Quotation Mark case ((int)'\u203A'): sbOriginal.setCharAt(isb, '\''); break; // Single right-Pointing Quotation Mark case ((int)'\u02DC'): sbOriginal.setCharAt(isb, '~'); break; // Small Tilde case ((int)'\u2013'): sbOriginal.setCharAt(isb, '-'); break; // En Dash case ((int)'\u2014'): sbOriginal.setCharAt(isb, '-'); break; // EM Dash default: break; } } } public static String windows1252ToIso8859(String strOriginal) { if (null==strOriginal) { return null; } StringBuilder sbOrig = new StringBuilder(strOriginal); windows1252ToIso8859(sbOrig); return sbOrig.toString(); } </code></pre></li> <li><p>Finally changed my setter method of the DAO layer to use the above mentioned utility as shown below.</p> <pre><code>public String getIncidentShrtDescC() { return this.incidentShrtDescC; } public void setIncidentShrtDescC(String incidentShrtDescC) { this.incidentShrtDescC = AppGlobalUtil.windows1252ToIso8859(incidentShrtDescC); } </code></pre></li> </ol> <p>Combination of all of the above helped in resolving the issue. Hope this post helps some wandering soul facing the same problem.</p> <p>Happy Coding.</p>
 

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