Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to print console output

843840Jan 17 2008 — edited Jan 18 2008
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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 15 2008
Added on Jan 17 2008
6 comments
750 views