I have a string that must be used to be passed into a JavaScript function. I have tried many ways, but I still cannot make it to work.
<a href="javascript:goFac('<%=name%>')"><%=name%></a>
The name field is a string that contains single quotes such as It's Morning. I have tried to use:
String nameString = rs.getString("name");
nameString = nameString.replaceAll("'","\'");
<a href="javascript:goFac('<%=nameString %>')"><%=nameString%></a>
And also
nameString = URLEncoder.encode(nameString);
And also
nameString = nameString.replaceAll("'","'");
And also
nameString = nameString.replaceAll("'","'");
I still cannot get it to work. And also I can't go for EL.