Where System.out writes in a servlet?

青春壹個敷衍的年華 提交于 2019-11-29 09:31:13

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

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

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!