From: Myron Ahn [mailto:[EMAIL PROTECTED]]

> For velocity, how do you go about escaping text in HTML?

What do you mean?  Things like replacing with entities?

<  -->  &lt;

> I used the org.apache.velocity.anakia.Escape object, which
> works well, but
> is there a more elegant way that doesn't require inserting an
> object into
> the context?

Are you bothered by having to place it in there each time, or having to use
it each time?

For the latter, I am not sure how something could automatically decide when
you want something escaped.

For the former, if you are using servlets and deriving from VelocityServlet,
you could do something like override  createContext(req, resp)
and have the Escape (or like) object placed in there.

Then, every context you use from that servlet will have that object
available, and you don't have to think about it.

I am sure others have more elegant solutions :)

geir


Reply via email to