How to deal with sigle quote in javascript in jsp page?

onclick= “_deleteWPSchemeData(${viewWPMasterGrid.id}, ‘${viewWPMasterGrid.name}’)”

${viewWPMasterGrid.name} retutrns me a string(for e.g. W.P.WINT OFF ALL’10) which often has single quote character so from the calling javascript method I am not getting the second parameter at all. How to deal with problem?

You’ll need to escape the output.
I’m not sure how to do that in Java (I don’t speak Java), but Googling for ‘jsp escape javascript’ should help you along.

I’ve already searched it also got some reference but I’m facing particular problem for this EL in jsp. Anyway thank you for your valuable suggestion.

EL? What’s that?

EL is Expression Language.
${viewWPMasterGrid.name} returns a string that may comprises a single quote.

Maybe something like this:


<c:out value="${viewWPMasterGrid.name}"/>

(as I said, I don’t speak Java or JSP :slight_smile:

http://stackoverflow.com/questions/475839/how-can-i-escape-special-html-characters-in-jsp