olamundo
olamundo

Reputation: 24991

use the c:out tag on a String

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?

Upvotes: 1

Views: 1686

Answers (1)

cherouvim
cherouvim

Reputation: 31903

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

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

Upvotes: 2

Related Questions