Forums Register Login

response object - Body Content

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
do you want response to be written in file and HTML to be sent to client?
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

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 ]
+Pie Number of slices to send: Send
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.
These are the worst of times and these are the best of times. And this is the best tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 992 times.
Similar Threads
CLASSPATH - Environment Variable
Polymorphism - InstanceOf
adapting content for wireless web services
Dynamic Image Creation
How does the browser interpret the response inputstream sent by the server?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 04:49:51.