This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes jsp output to a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "jsp output to a file" Watch "jsp output to a file" New topic
Author

jsp output to a file

Ted Dong
Greenhorn

Joined: May 16, 2001
Posts: 15
Hi,
I want to send the output of a jsp file (ie, the html that the jsp page creates) to a file on the server.
Basically, I want to have the html that the user sees when they do view source from the browser, saved to a file on the server.
I know I can use FileOutputStream to create files on the server but I don't know what to pass into the write() method to write the output of the jsp page.
Thanks in advance.
Hardy Chou
Greenhorn

Joined: Jun 27, 2001
Posts: 27
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("your.log")));
pw.println("print something here");
pw.print("\n print also something here");
pw.flush();// coz u used print();
pw.close(); //close the stream
Ted Dong
Greenhorn

Joined: May 16, 2001
Posts: 15
Thanks for the reply.
So, since I want my output (html) to be written to a file do I have to print the following:
pw.println{"<HTML><HEAD></HEAD><BODY>");
pw.println("the rest of the html....");
Or is the output stored in the buffer somewhere and could I just send the buffer contents to the printwriter?
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp output to a file
 
Similar Threads
welcome file in web.xml
Writing JSP response content to file
Store JSP output in HTML File
Anyone know how to save the response (html) of a jsp page to a file
html into html