Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet responce to textfile

 
sripad_devaraju
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Amir Kamran
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic