File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes response object - Body Content Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "response object - Body Content" Watch "response object - Body Content" New topic
Author

response object - Body Content

Omkar Shetkar
Ranch Hand

Joined: Jun 22, 2006
Posts: 42

Hi,

I wanted to store the HTML body content of the response object in a different file location of the local system instead of displaying on the browser on request from the user.
Can anybody guide me in this regard?

Thanks
Omkar V S


http://mynotesontech.wordpress.com/
Prabhu Venkatachalam
Ranch Hand

Joined: Nov 16, 2005
Posts: 502

do you want response to be written in file and HTML to be sent to client?


Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
Omkar Shetkar
Ranch Hand

Joined: Jun 22, 2006
Posts: 42

Hi,

I want the HTML content of the response object to be stored in a file e.g., in word or RTF format.

For example, suppose in Google, I type the search term as "India" then the results will be displayed in the next web page. But here what I want is to store that result page in a file (in RTF/PDF/Excel format) of my local system instead of opening in the browser.

Actually this functionality is needed for exporting the crystal report to RTF/PDF/Excel format on request from the user.

Thanks
Omkar V S
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
You can't do that with JSP, they're hardwired to write to the ServletOutputStream.
What you might attempt is creating an interceptor in the application server that intercepts the outputstream, and writes the output to file, then resets the stream and sends it to the client.

Or you can use a different technology like a dispatcher servlet that generates output using XSLT transformations of XML data.
If you do that it's simply a matter of writing the results of that transformation first to file and next to the ServletOutputStream.


42
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by Omkar Shetkar:


For example, suppose in Google, I type the search term as "India" then the results will be displayed in the next web page. But here what I want is to store that result page in a file (in RTF/PDF/Excel format) of my local system instead of opening in the browser.



If your requirement is that , you will open an IE instance and google for "RAHUL" and the output is to be written to a file , then its not possible.But there exists a complicated solution to this , though never tried ,but will go like this :- sniff all the packets from that particular site and then from the HTTP response from those packets and then write the content to a file.

Or , you want to write a program to fetch the data from a URL and store that in a file , in that case you can try writing a bot , which would do all the crawling for you.
[ December 16, 2006: Message edited by: Rahul Bhattacharjee ]

Rahul Bhattacharjee
LinkedIn - Blog
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

You cannot write to the client file system. Period.

What you can do is to use a servlet to format the output to whatever file type you wish, set the response headers appropriately, and stream the file to the browser. The user will then be given an opportunity to download your file.

As previously stated, JSP is not an appropriate technology for this purpose.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: response object - Body Content