Where System.out writes in a servlet?

2019-01-26 06:27发布

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?

4条回答
萌系小妹纸
2楼-- · 2019-01-26 06:52

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.

查看更多
来,给爷笑一个
3楼-- · 2019-01-26 06:53

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 [...]

查看更多
家丑人穷心不美
4楼-- · 2019-01-26 06:58

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

查看更多
ゆ 、 Hurt°
5楼-- · 2019-01-26 07:11

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.

查看更多
登录 后发表回答