How to print values in console (like System.out.println() in java) using scriplet in javascript while a function is called ? if i used System.out.println("test") in scriplet the values is getting printed while a jsp form is loading but i want it to print only when a java script is called.
Asked
Active
Viewed 7.1k times
7
SeniorJD
- 6,946
- 4
- 36
- 53
hemalatha karunakaran
- 73
- 1
- 1
- 3
-
you can use console.log(""); for client side logging. And if required you can log errors using the link above. Otherwise i am afraid simple logging from client side to server site cannot be achieved. – Lakshmi Jan 03 '14 at 10:08
2 Answers
11
System.out.println ("test");
That is java and you cannot execute that on client side.
You might looking for
console.log("");
And while page loading it's printing because the jsp you are submitting processing on server side and java code executes there.
General Grievance
- 4,555
- 31
- 31
- 45
Suresh Atta
- 120,458
- 37
- 198
- 307
-
thnx for the quick response,but this can only be user with browser but i want to print console in my server log file – hemalatha karunakaran Jan 03 '14 at 10:01
-
No ,you cannot.You should log the user activity on server side. Not with what he is doing on client side. Probably you need that link which Lakshmi added in comments – Suresh Atta Jan 03 '14 at 10:04
1
Use:
console.log('Hello World!');
Moritz Petersen
- 12,902
- 3
- 38
- 45
-
1This does not print anything in the console if you write it in the jsp. This can only work in JS. – clever_bassi Nov 10 '15 at 21:47