-1

Can someone please tell me what is the error in my code? Without using the c:out I can display the output.

<a class="popUp" href="javascript:showMessage(<c:out value='${myHistory.userId}' />, <c:out value='${myHistory.userName}' />);">Click Here</a>

When I click the link Click Here nothing is happening. Please tell me how to use C:Out or fn:escapeXml in my code. Can also suggest me if there are other alternatives.

I have referred these links to write my code.

Jslt c out in a href

XSS prevention in JSP/Servlet web application

Community
  • 1
  • 1
Yithirash
  • 377
  • 3
  • 6
  • 18
  • Did you checked the HTML code resulting of the compilation of the JSP ? You are talking about Xml, why ? (just in case or is it Xml ?) – AxelH Oct 21 '16 at 06:27

1 Answers1

0

You've got tags inside another tag, which is not allowed. You should use ${} instead of <c:out ... />. I also suggest to use onclick to trigger the js function.

<a class="popUp" href="#" onclick="javascript:showMessage('${myHistory.userId}', '${myHistory.userName}');">Click Here</a>
micaro
  • 946
  • 6
  • 10