aspose file tools*
The moose likes Servlets and the fly likes how to get line Break in Servlet output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to get line Break in Servlet output " Watch "how to get line Break in Servlet output " New topic
Author

how to get line Break in Servlet output

Manjesh Patil
Ranch Hand

Joined: Sep 24, 2010
Posts: 41

Hi I have the following requirement





When I write this to browser from servlet, the output will be printed in the same line but I am expecting in two lines (in text form not HTML form which can be achived using <br/>).
If I use System.out.println(s) , it prints as I am expecting.

I have tried the following things but no gain!



Also I have noticed one thing that . I am using JRE6 WINDOWS 7 and ECLIPSE
is this the problem?

can someone help me..?
thanks in advance
Ma
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Manjesh Patil wrote: the output will be printed in the same line

I doubt that it is printing output. since you are creating PrintWriter Object. you should flush the output stream, after the write
Manjesh Patil
Ranch Hand

Joined: Sep 24, 2010
Posts: 41

Thanks for Reply

yes ...there is . It writes the output but in single line.............

how to configure these outputstreams so as to consider the new line character?

-thanks
Ma
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61760
    
  67

Think! Stop, and think!

Where is the output being sent? Answer: to a browser.

So what does the browser do with the line break?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bill Li
Greenhorn

Joined: Jul 25, 2012
Posts: 1
I think you should encode these strings when you output to the brower.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61760
    
  67

Bill Li wrote:I think you should encode these strings when you output to the brower.

No.

What creates a line break in the browser? Not the answer: a new line. So what is the answer?
vinayak jog
Ranch Hand

Joined: Apr 01, 2011
Posts: 81

the tag which used to break the line..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get line Break in Servlet output