• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to display output in New Line using servlets

 
Vineet Menghani
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I am new to this group.
Just need to know how to display output in the newline using servlets.
As \n works fine in java, but it doesn't seem to be working in servlets.
Is there any other escape sequence or way to do the same.


Kindly suggest.
Thanks & regards,
Vineet
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your servlet output is most likely being interpreted as HTML by the browser. You need to either tell the browser that you are sending plain text (by setting the content type header appropriately) or generate HTML markup to display the text with the formatting you desire.
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which, to state the obvious, is the <br /> tag for newlines.

If your output is already white space formatted, then you can wrap the HTML tag <pre> </pre> around your output.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic