File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes System.out.println in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "System.out.println in jsp" Watch "System.out.println in jsp" New topic
Author

System.out.println in jsp

Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
Hi , in my system "System.out.println" is not working . But i see this code .
<% System.out.println( "Evaluating date now" );
java.util.Date date = new java.util.Date();
%>
Will system.out.println work in jsp or only out.println will work
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

Of course it works. It's just not doing what you incorrectly expect. It writes the output to the console.

By the way, still putting Java code in JSPs? Not a good practice.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
But i have tried , System.out.println not working . only out.println works fine.
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 537

As, Bear pointed out, System.out.println will print in the console, means in the server logs, not in the resulting page, out.println, will print in the resulting page, so if you are sure, its not printing in the console, can you tell, are you getting any exception, or its just not working at all..
Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
i supposed to print value of a display page . while using out.println(a); means value of a printed in resulting page.
but system.out.println(a); means nothing displayed in resulting page
Eswar Nec
Ranch Hand

Joined: May 02, 2010
Posts: 105
Hi,

Here i use the word S.O.P instead of System.out.println and O.P instead of output.println
If you have use Netbeans IDE, then easily identify the difference between S.O.P and O.P.


Netbeans IDE have output window. This window has some tabs including
1. Apache Tomcat(version) Log and
2. Apache Tomcat(version) . Version like 5.5 0r 6.018 anything.


The output of 5,6(line number) have displayed in second tab (netbeansIDE) like Apache Tomcat 6.0.18
Otherwise You can see apache tomcat server log file --> (System.out.println content).

Then Output of 9,10(line number) have displayed in browser window. --> (output.println content)

If you want any thing displayed in browser, better you will use output.println().


Wake up! Don't let your smile be snatched away by anybody!
Regards, Eswar
Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
can you give reason for why system.out.println not displayed in browser window
Eswar Nec
Ranch Hand

Joined: May 02, 2010
Posts: 105
Rajendra Prakash wrote:can you give reason for why system.out.println not displayed in browser window


You refer this link .
http://www.java-forums.org/advanced-java/12575-difference-between-system-out-println-out-println.html

I think you will get some idea about this

Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

ItDoesntWorkIsUseless. Next time, try to explain your problems more specifically. After reading your first post, we have no idea that you want to print something in the browser page.


[My Blog]
All roads lead to JavaRanch
Eswar Nec
Ranch Hand

Joined: May 02, 2010
Posts: 105
Christophe Verré wrote:ItDoesntWorkIsUseless. Next time, try to explain your problems more specifically. After reading your first post, we have no idea that you want to print something in the browser page.


Hi,
I don't know. Which post you mention?

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

@Eswara: Christopher wasn't talking to you.

@Rajendra: Christopher *was* talking to you. Your question was answered several times, including in Bear's first response. System.out.println writes to the system console. That is *NOT* the same thing as the JSP page. IN a JSP, out.println *does* write to the JSP page, because "System.out" and "out" are two completely different variables, which you'd see if you printed either of them to the JSP. Or the system console. Using the appropriate variable.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Thanks David. Eswara, sorry for the confusion. I was referring to Rajendra's first post.
Eswar Nec
Ranch Hand

Joined: May 02, 2010
Posts: 105
Christophe Verré wrote:Thanks David. Eswara, sorry for the confusion. I was referring to Rajendra's first post.


Thanks for your reply. Cool
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: System.out.println in jsp