vivek_jonam
vivek_jonam

Reputation: 3297

Where System.out writes in a servlet?

I am just curious to know, what happens when System.out.print() is called in a servlet?
Where does it write the text?

Or is there any significant use of System.out in a servlet?

Upvotes: 13

Views: 14951

Answers (4)

JDGuide
JDGuide

Reputation: 6525

No, there is any significant use of System.out in a servlet. Beacause , Servlet is a web technology for generating dynamic web pages. Normally , it returns response to HTML page. So, there is no need for print data on Console.

For Console print, there are many other options except Servlet. But still if we want to print data on console then you can write inside service(),doGet(),doPost() and other methods also :-

System.out.println("YOUR MESSAGE");

But, it is recommended to avoid that.

Upvotes: 1

PrasoonMishra
PrasoonMishra

Reputation: 83

It will write in the console .System.out is generally used in servlet to verify some piece of code is working,which we can refer in console.

Upvotes: 1

Jérôme Radix
Jérôme Radix

Reputation: 10533

It depends on your servlet container.

For Tomcat :

When running Tomcat on unixes, the console output is usually redirected to the file named catalina.out. The name is configurable using an environment variable. (See the startup scripts). Whatever is written to System.err/out will be caught into that file.

For jetty, you can redirect standard output to a file :

It is possible to redirect all output sent to stderr and stdout to a file that can be rolled over [...]

Upvotes: 11

Pramod Kumar
Pramod Kumar

Reputation: 8014

System.out.print() writes on Server Console.

Upvotes: 5

Related Questions