Hi, I have a JSP page and I would like to print STDOUT to the page. Is this possible?
I've seen a few methods and none work for me:
BufferedReader reader = new BufferedReader(System.out);
String input = reader.readLine();
out.println(input);
*** Error: Type BufferedReader was not found.
FileOutputStream out;
PrintStream ps; // declare a print stream object
try {
// Create a new file output stream
out = new FileOutputStream("myfile.txt");
// Connect print stream to the output stream
ps = new PrintStream(out);
ps.println ("This data is written to a file:");
System.err.println ("Write successfully");
ps.close();
}
catch (Exception e){
System.err.println ("Error in writing to file");
}
*** Error: Duplicate declaration of local variable "out".
*** Error: The type of the left-hand side in this assignment, "javax/servlet/jsp/JspWriter", is not compatible with the type of the right-hand side expression, "java/io/FileOutputStream".
*** Error: No match was found for constructor "PrintStream(javax.servlet.jsp.JspWriter)".
So what's next?
How can I call the console without writing to a file first?
I would like AJAX to show console output in real-time.