aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Did you ever use System.out.println() as one debug tool in J2EE? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Did you ever use System.out.println() as one debug tool in J2EE?" Watch "Did you ever use System.out.println() as one debug tool in J2EE?" New topic
Author

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

Sam Sun
Ranch Hand

Joined: Feb 01, 2005
Posts: 60
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

Joined: Aug 24, 2004
Posts: 250
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 ]

Sawan<br />SCJP,SCWCD,SCBCD<br /> <br />Every exit is an entry somewhere.
Anand Wadhwani
Ranch Hand

Joined: Mar 21, 2005
Posts: 151

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.


SCWCD 1.4<br />---------------------<br />Ability is what you're capable of. <br />Motivation determines what you do. <br />Attitude determines how well you do it.<br />---------------------
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
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


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Sam Sun
Ranch Hand

Joined: Feb 01, 2005
Posts: 60
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Did you ever use System.out.println() as one debug tool in J2EE?
 
Similar Threads
ServletContextListener
NullPointer Exception
Compile error
Timerapp; classdefnotfound exception
Netbeans & Tomcat Problem : Error messages included!