How to escape apostrophe or quotes on a JSP (used by JavaScript)

I prefer to avoid scriptlets in the middle of my page and was having to use them (increasingly often) to escape strings when used in JavaScript code. I wanted an Expression Language (EL) way of escaping the strings. I created a very small custom taglib that I use for just this purpose: Utilities.java: package com.mycom.taglibs; … Read more

How to put unprocessed (escaped) words inside String.Format

You can surround literal strings with quotes, which for longer strings is probably easier and a bit more readable than escaping every character with a backslash: str = String.Format(“{0:MMM d ‘at’ m:mm”+yearStr+”}”, dt); See Custom Date and Time Format Strings in MSDN Library (search for “Literal string delimiter”). (And did you mean h:mm instead of … Read more

Escape Quotes In HTML5 Data Attribute Using Javascript

There is no way around it, you have to escape the values properly, or the HTML can’t be parsed properly. You can’t use Javascript to correct the code after it is parsed, because then it has already failed. Your example with proper HTML encoding would be: <p class=”example” data-example=”She said &quot;&lt;abbr title=&quot;What The F***&quot;&gt;WTF&lt;/abbr&gt;&quot; on … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)