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?
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?
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.