• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

New line in quoted string

 
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic