0

How can I change to correct below code?

<%!
    public String renderComment(String comment) {
        return comment.replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\n", "<br />");
    }
%>

<c:forEach var="answer" items="${answerList}" varStatus="status">
    <%=renderComment(${answer.cn})%> <!-- This is wrong. -->
    <%=renderComment(answer.cn)%> <!-- This is wrong.-->
    ${renderComment(answer.cn)} <!-- This is wrong, too! How can I do? -->
</c:forEach>
Jaime
  • 1,928
  • 1
  • 15
  • 18

1 Answers1

0

I guess, there is no way.
However, I found a another way.

How to call a static method in JSP/EL?

Probably, this way is best.

Community
  • 1
  • 1
Jaime
  • 1,928
  • 1
  • 15
  • 18