File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Velocity new line Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Velocity new line" Watch "Velocity new line" New topic

Velocity new line

Konstantin Chikarev

Joined: Feb 19, 2005
Posts: 26
Hi all! I didn't find how to set new line in velocity variable. Construction like #set ($test = "line1\n line2") doesn't do that.

Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
I've done lots with Velocity, but surprisingly never had to do this.

Have you tried doubling the backslash?

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Marco Ehrentreich
best scout

Joined: Mar 07, 2007
Posts: 1294


are you possibly using Velocity templates for HTML pages? Then of course a newline in the source code wouldn't be the same as a newline in your HTML page (<br> . That's just a thought because I personally have no experience with Velocity...

Konstantin Chikarev

Joined: Feb 19, 2005
Posts: 26
I don't use velocity for HTML.
I've tried It renders as . renders as
I am constructing template from peaces and than giving it to velocity. May be that's the cause.
I agree. Here's the link:
subject: Velocity new line
It's not a secret anymore!