File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Did you ever use System.out.println() as one debug tool in J2EE?

 
Sam Sun
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I saw in HF page 260 that they used System.out.println() in the AttributeListener. I tried it but nothing happened. Didn't write anything in the console window. How about you? Did you ever use System.out.println() in the J2EE?

Here is the code. What do you think will happen in the console when this class is instantiated?

***********************************************************
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class MyServletContextListener implements ServletContextListener {
public void contextInitialized (ServletContextEvent e){
ServletContext sc = e.getServletContext();

java.util.Date date = new java.util.Date();
sc.setAttribute("time", date.toString());

System.out.println("I'm here.");
}

public void contextDestroyed(ServletContextEvent e){}

} //end class MyServletContextListener
***********************************************************

[ June 26, 2005: Message edited by: Bruce Sun ]

[ June 26, 2005: Message edited by: Bruce Sun ]

[ June 26, 2005: Message edited by: Bruce Sun ]
[ June 26, 2005: Message edited by: Bruce Sun ]
 
sawan parihar
Ranch Hand
Posts: 250
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check that your Listener was called. System.out.println() will print on the console. You may want to post your code here .
[ June 26, 2005: Message edited by: sawan parihar ]
 
Anand Wadhwani
Ranch Hand
Posts: 151
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Did you ever use System.out.println() in the J2EE?


The System class has nothing to do with J2EE. J2EE is a framework. And System class is a standard java class.

The System.out.println will execute on server side when used in a java-based web application, and this will print the given data to a log file maintained by servlet container.

I would suggest put some ***** \n\n --->> kind of characters in your print string so that you can clearly see the string coming on console. It should work.
 
Narendra Dhande
Ranch Hand
Posts: 951
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Where the output of the System.out.println will displayed is depends on the app server. The Tomcat shows the output in server log file.

Thanks
 
Sam Sun
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Anand Wadhwani:

I would suggest put some ***** \n\n --->> kind of characters in your print string so that you can clearly see the string coming on console.


I tried like this:
System.out.println("I am here. \n\n");
It wasn't shown in the console. But I found it in the stdout_20050607.log.
Please continue to suggest me and let's try to work it out.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic