It's not a secret anymore!
The moose likes HTML, CSS and JavaScript and the fly likes New line in quoted string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "New line in quoted string" Watch "New line in quoted string" New topic
Author

New line in quoted string

PradeepPillai Pradeep
Ranch Hand

Joined: Nov 15, 2005
Posts: 186
I have a bunch of strings getting in my jsp and I iterate in my jsp. The first part of the string is like a Title and the second part is like a body. I want to put a line break after the first part. I tried putting a new line character (\n) after the first part. I tried \n\r, it didn�t work.
Example: �Title \n Body�
The output is
Title Body.
But I want to print
Title
Body
In my jsp.
Is there any way?
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19739
    
  10

"Didn't work" meaning that in the browser you didn't see the two words on different lines? That would be because HTML converts newlines and other whitespace like them to a single blank. If you want two words to show up on separate lines in HTML then you need a <br> element or some other HTML method of doing that.

Or "Didn't work" meaning something else?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63342
    
  70

Do you know HTML? JSP is just a templating technology to send HTML to the browser. So the browser will follow whateer markup the response HTML indicates.

And in HTML, the new-line charater is ignored.

Moved to the HTML forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: New line in quoted string
 
jQuery in Action, 3rd edition