Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

System.out.println() and out.println() are not working  RSS feed

 
Zeona Neo
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Iam using netbeans 8.0.2 and using Tomcat Server. I,m doing a project in JSP using Struts framework. Whenever I use out.println() or system.out.println(), it is not showing any message. Please help me... Do I need to change any settings inside Netbeans....
 
Campbell Ritchie
Marshal
Posts: 55698
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

You have arrived in the wrong forum; this is for discussing the website. But don't worry: I shall move you to somewhere more appropriate.

What exactly happens when you write System.out.println()? We can only help if we have the full details. Have you read in the documentation what System.out.println() actually does?
 
Zeona Neo
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for choosing wrong forum....I was not knowing that where to post questions as I'm first to the site....
Actually in my Netbeans, whenever I run the project it is not showing any results in the output console window which I gave in system.out.println(). In output window it is only showing that buil successfull message and also I'm not able to print any messages in the webpage also as the out.println() is also not working. Also, the Tomcat Server output window is not appearing in the Netbeans.
Thanking You for spending your valuable time.....
 
Campbell Ritchie
Marshal
Posts: 55698
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What did you expect System.out.println() to print? Did you read the documentation I showed you earlier? Did you follow the links until you got to the println() method? Conveniently, the link has a “See Also:” list which will take you straight to println. That should tell you what to expect.
It should make no difference whether you are using Netbeans or the command/terminal windows.
Don't know anything about the Tomcat window, I am afraid.
 
Zeona Neo
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Sir....

I need to know, if I have an SQL query variable say abc and I need to know what value abc is getting after execution... how will i print the variable to see whether the variable is getting any value or not???
 
Stephan van Hulst
Saloon Keeper
Posts: 7806
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your other topics lead me to believe that it's not a variable from an SQL query that you want, but a query string parameter from an URL.

Show us some of your code involving the println(). Please make sure that if you use println("Hello World!") that it is working.
 
Campbell Ritchie
Marshal
Posts: 55698
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I merged your stuff with the following thread. I hope that is okay by you.
 
Stephan van Hulst
Saloon Keeper
Posts: 7806
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean variables in stored procedures? Can you give us an example of what you need?
 
Zeona Neo
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Sir..
I was actually trying to send a reply...
But unfortunately I clicked on new topic and by mistake I posted this....
Sorry....

I want to print the value of variables inside the output console window to check whether the variable is getting any value or not... I'm not able to print the value using System.out.println().

For Example;
String uname=request.getParameter("email1");
String pwd=request.getParameter("pswd1");
System.out.println(uname);
System.out.println(pwd);
 
Campbell Ritchie
Marshal
Posts: 55698
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it is best to merge your two threads.
What exactly happens? What do you see on screen? System.out.println always works. Where is the getParameter method from? It does not appear to be from an SQL query. What are you doing with Exceptions? We can only help you if we know the full details.
 
Zeona Neo
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The below code is my struts action class code, in that i have given system.out.println() and out.println(). But no any values are displaying on the execution of the project.
 
Stephan van Hulst
Saloon Keeper
Posts: 7806
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So can you see that it prints "Logged In Successfully" or "Invalid Username or Password"?

How do you know that the request successfully reaches your execute() method?

Another unrelated but important issue: NEVER store passwords in your database as plain text. Use a proper password based key derivation function, and store the key in your database instead. You can use something like bcrypt or PBKDF2.
 
Zeona Neo
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Iam not able to see any messages like "Logged In Successfully" or "Invalid Username or Password". But after login it is directly going to corresponding pages like admin home page or user homepage without showing any messages and if the password or username is incorrect then it showing the failure page without any messages. What should I do display successful messages....please help me...

Thanking You.....
 
Tim Holloway
Bartender
Posts: 18709
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not safe to use the System.out or System.err output facilities in a web application. There's no telling where the output may go. It may even get discarded. Use a logger.

It's also not recommended to use brute-force connection methods to get a Connection in a webapp. It's better to use a database connection pool. But that's something you can do once you have everything else worked out.

Of course, in a professional-quality webapp, anyone who writes their own login code is just asking to be hacked anyway. Leave that for homework assignments. On a computer that you don't care if someone takes it over. Or, for that matter, any other computer on the LAN.

Still, you didn't set up your SQL to retrieve the password in plain text from the database, so there's hope for you yet.

Note to Campbell: When Tomcat is being run by an IDE, commonly the IDE will redirect the Tomcat JVM's stdio streams to a "window" (or often a window pane). So stuff that would normally go to the Tomcat catalina.out file is visible in the IDE. But, as I said earlier, there's no guarantee. It could just as easily get discarded, especially if the IDE's run settings aren't adjusted properly.
 
Stephan van Hulst
Saloon Keeper
Posts: 7806
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you running your application?
 
Zeona Neo
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK!...
So How will I display the Succesfull messages in a popup window..... Iam running the project directly from Netbeans...
How can I change the settings to see the Tomcat Output window....
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is System.out prints to the Console which you do not have running inside Tomcat. You need to configure and use logging for you application. Her is a good discussion of how to do this.

https://tomcat.apache.org/tomcat-6.0-doc/logging.html
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!