*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Mock exam question doubt? 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 "Mock exam question doubt?" Watch "Mock exam question doubt?" New topic
Author

Mock exam question doubt?

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9400
    
    2

Guys,



The question above is from David Bridgewater and the answer is given as E. I thought C?? won't the System.out.println write to the server console (log)???


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Hi Shankar,

System.out.println will write output to standard output device.

For logging purpose: you need to use ServletContext.log() method.


Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
Sergio Tridente
Ranch Hand

Joined: Mar 22, 2007
Posts: 329

I think E is the correct answer.

Note that the example is using two kind of scripting elements: declarations (<%! %> and scriptlets (<% %> . The Date code is part of a scriptlet block, so it will be put inside the _jspService method during translation. The other two blocks are declarations, which means they will be put outside the _jspService method. What is more, those two blocks are declaring a jspInit method, which will be run only once during servlet initilization (that's why the second time you'll see no output in the log).

I hope I made myself clear.

PS: I am copying my response from the other thread + some corrections to try to make it clearer.
[ April 23, 2007: Message edited by: Sergio Tridente ]

SCJP 1.4 (88%) - SCJP 5.0 Upgrade (93%) - SCWCD 1.4 (97%) - SCBCD 5.0 (98%)
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9400
    
    2

Srinivasan,

As you say the System.out.println() methods outputs to the tomcat console and it is not the same as log. Am I right?
Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361
I agree with Sergio, the answer should be E. Regarding the
System.out.println, it prints to a text file inside the logs directory of the tomcat. If you are using an IDE like Netbeans, this text will appear in an output window too.
[ April 23, 2007: Message edited by: Khaled Mahmoud ]

SCJP, SCJD,SCWCD,SCDJWS,SCEA 5 MCP-C#, MCP-ASP.NET - http://www.khaledinho.com/
Life is the biggest school
Aniket Patil
Ranch Hand

Joined: May 02, 2006
Posts: 218
As you say the System.out.println() methods outputs to the tomcat console and it is not the same as log. Am I right?


Depends on the version of Tomcat used. Some output to the console, other to a text file.


SCJP 5.0 | SCWCD 1.4 <br /> <br />If you don't know where you are going, any road will take you there!
Aniket Patil
Ranch Hand

Joined: May 02, 2006
Posts: 218
As you say the System.out.println() methods outputs to the tomcat console and it is not the same as log. Am I right?


Depends on the version of Tomcat used. Some output to the console, others to a text file.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9400
    
    2

I'm using an IDE and it outputs to the console!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9400
    
    2

Many IDE's many confusions
 
GeeCON Prague 2014
 
subject: Mock exam question doubt?