Where System.out writes in a servlet?
Asked Answered
R

4

13

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?

Revanche answered 16/8, 2012 at 11:38 Comment(2)
esus.com/javaindex/j2ee/servlets/servletoutput.htmlNecker
Displays output in the server consoleAldehyde
G
11

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

Goldberg answered 16/8, 2012 at 11:49 Comment(0)
D
5

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

Denude answered 16/8, 2012 at 11:39 Comment(2)
Server>> Apache Tomcat >> Right click >> View Server OutputTetrachloride
@Tetrachloride which is where on IDEA?Monumentalize
H
1

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.

Hand answered 16/8, 2012 at 12:6 Comment(0)
G
1

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.

Grannie answered 16/8, 2012 at 12:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.