在Eclipse中,Java EE Servlet不会输出到控制台 [英] In Eclipse Java EE servlet does not output to console

查看:319
本文介绍了在Eclipse中,Java EE Servlet不会输出到控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的 servlet ,它使用PrintWriter创建HTML,并通过 System.out.prinln( )在相同的doGet()方法中。

I have a simple servlet that creates HTML with PrintWriter and writes to console via System.out.prinln() in the same doGet() method.

我在Eclipse中看到了HTML部分(Java EE透视图),但是控制台视图中没有任何内容。 servlet中的 stdout 应该在哪里出现?

I see HTML part in Eclipse (Java EE perspective) but there is nothing in the Console View. Where should stdout from a servlet appear in Eclipse?

代码如下:

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");
}

如果有什么不同,这里的版本是Eclipse Juno,Java EE 7 ,GlassFish 4服务器。

If it makes any difference here are the versions, Eclipse Juno, Java EE 7, GlassFish 4 server.

推荐答案

您将找到 System.out.println Web容器日志中的输出,即GalsFish日志中的输出。

You will find the System.out.println outputs in your web container logs i.e in GalssFish logs.

Eclipse仅在独立应用程序中而不在Web应用程序中在自己的控制台中打印sysout。原因是,Web应用程序部署在Web容器中并在这些容器下运行。 Eclipse只是帮助完成了部署应用程序的过程,但并未在其中部署Webapps。因此,您将在Web容器(例如glassfish)中找到日志。

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.

这篇关于在Eclipse中,Java EE Servlet不会输出到控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆