aspose file tools*
The moose likes Servlets and the fly likes How to display output in New Line using servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to display output in New Line using servlets" Watch "How to display output in New Line using servlets" New topic
Author

How to display output in New Line using servlets

Vineet Menghani
Greenhorn

Joined: Sep 04, 2003
Posts: 3
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

Joined: Jan 10, 2002
Posts: 61433
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
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.


Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
 
 
subject: How to display output in New Line using servlets