File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes servlet responce to textfile 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 "servlet responce to textfile" Watch "servlet responce to textfile" New topic
Author

servlet responce to textfile

sripad_devaraju
Greenhorn

Joined: May 15, 2002
Posts: 13
Hi Guys,
my problem is like this,
I am dynamically generating a html page using servlet.I don't want to send this HTML code ro browser(which parses it and display HTML page),insted i want to send HTML code to a text file(using file object in java.io package).I am not getting how to write it?
I would be thankful to you if any of you guys could clear my doubt ASAP.
Thanks


sripad devaraju
Amir Kamran
Ranch Hand

Joined: Apr 21, 2002
Posts: 48
hello!
The writing process to a file is same as u do to wrint the html to browser just create the out object something like this.
PrintWriter out = new PrintWriter(new FileWriter(filename));
now when u call out.print("<html>...") writes in the file specified.
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Just out of sheer curiosity -- why would you want to do this??? It really sounds like you don't want a servlet at all...
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: servlet responce to textfile
 
Similar Threads
replace attribute value of html using java
How to save the servlet response to a file !
problem with images in html page
HTML Table as XML File using JavaScript
How to read html file?