views:

35

answers:

1

Inside my jsp page, I have a string I want to show, but it might contain '<' or some other character that I want to escape so it will not mess up the rest of the HTML.

I know c:out can do this, but as far as I understood, it can only work on bean properties, and not on a simple string.

Is there a way of doing something like

<c:out value="${myString}"/>

where myString is a simple java String defined in the scope of the page?

Or am I completely missing the point?

+2  A: 
<c:out value="${myString}"/>

One way of having myString available is by having done request.setAttribute("myString", ...) somewhere before reaching the template.

cherouvim