In Eclipse Java EE servlet does not output to console
Solution 1
You will find the System.out.println
outputs in your web container logs i.e in GalssFish logs.
Eclipse prints the sysout in its own console only for standalone applications and not for web applications. The reason is that, web applications are deployed in web containers and are run under those containers. Eclipse just helps that process of deploying the applicaitons but it does not deploy the webapps within it. Hence you will find the logs in the web container i.e glassfish.
Solution 2
How to Log out to console: Right click on your glassfish and go to View Log File Make sure the console setting is directed at your server.log file:
PM 77-1
This is not me on the photo. I really like this image found on the Web, when I needed an avatar for a different site. #SOreadytohelp
Updated on June 05, 2022Comments
-
PM 77-1 almost 2 years
I have a simple
servlet
that creates HTML with PrintWriter and writes to console viaSystem.out.prinln()
in the same doGet() method.I see HTML part in Eclipse (Java EE perspective) but there is nothing in the
Console View
. Where shouldstdout
from a servlet appear in Eclipse?Code looks like this:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.println("<h2>Hello from Applet<h2>"); System.out.println("doGet"); }
If it makes any difference here are the versions, Eclipse Juno, Java EE 7, GlassFish 4 server.
-
PM 77-1 almost 11 yearsAre they viewable anywhere in Eclipse?
-
Mr_and_Mrs_D about 10 years@PM77-1: right click on the server Glassfish > logs - btw does not seem to print unicode chars (?)
-
kiltek almost 7 yearsmy log file seems to be empty, nothing is shown, despite the fact i am clicking though my app, it stopped working
-
Gene almost 7 yearsBased off the information you provided me, it's too hard to tell. I would check the server.log file in your file explorer. Make sure it's there. Maybe look at the glassfish configuration file for any log settings.