• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Anyone know how to save the response (html) of a jsp page to a file

 
Patrick Johnson
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know how to save/redirect the response html of a jsp page to a file ( i.e. with extension .html, .txt etc )? I want to save the html code that is sent to the browser on a server thus making it permanent.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you replace the output writer on Response with your own that writes everything to the original writer AND to disk at the same time?
This can't be good for performance. How do you plan to use the disk copy? I can conceive a strategy where you dynamically generate a page once, then use the disk copy after that, but there would be a good number of challenges!
 
chanoch wiggers
Author
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think you are generating a static site automatically so that dynamic updates are quick and automated - is that right? try to get a hold of a spider or web crawler that will do this for you (not done this myself so cant help any further.) i know some people have done this before - basically there are number of ways. You could use software like Cactus (http://jakarta.apache.org/cactus/) to generate your own code that will spider the site or perhaps that can go through it having been given a list of links and save the each page for you with an appropriate filename.
 
Pradeepta Bhattacharya
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use filters available in servlets package to trap the output and then store them in the html files or anywhere you might want to use. that the easier way i think .. or else you can write your own writer and then i think you need to map your writer to the runtime environment which is more complicated as usually the PageContext class will instanciate your jspwriter and maps it to the default jspfactory and makes it available to your jsp page and then replace your own writer with the one present in the jsp i.e implicitly you get the out object in jsp and you need to replace it with your own writer and then i hope you can use the writer to get the desired output.
I have tried out both the ways but i feel that the filters are the better and easier way to do the task. If i am wrong plz do inform me. Thanks in advance
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic