Get your CodeRanch badge!*
The moose likes HTML, CSS and JavaScript and the fly likes storing the responseText into a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "storing the responseText into a file" Watch "storing the responseText into a file" New topic
Author

storing the responseText into a file

yuvaraj KumarAmudhan
Ranch Hand

Joined: Aug 22, 2009
Posts: 110
i am making a request to the server with xmlhttprequest.
The server returns some text.
I need to store that responseText in a file. Is it possible to store the response in a file?


thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
No.


Ping & DNS - updated with new look and Ping home screen widget
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Do not use an XMLHttpRequest Object, send data to an iframe instead. Have the page set the correct headers to force a file download.

Eric
yuvaraj KumarAmudhan
Ranch Hand

Joined: Aug 22, 2009
Posts: 110

thank you sir!

is there anyway to pass the "css file" from the server to the client?
I need to fetch the "css file" from the database and that should be returned to the client.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
css file? you letting them download that?

You need to set these headers on the page:


Set a hidden iframe's url to the page you want to download.

Eric
yuvaraj KumarAmudhan
Ranch Hand

Joined: Aug 22, 2009
Posts: 110
thank you Eric sir!

Actually, I am making the request to the server via Ajax to get some css content.
The server replies the css content in "text" format.
i have to link that "css String" to the Html page like,
(<link rel="stylesheet" type="text/css" href="That Css String response" >.

I don't know how to achieve this.

Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Than you do not want to download it.

There i no need to make an Ajax request, just set the href of the link tag to the place your Ajax call is being made to

The DOM way to do it is as simple as:


Eric

yuvaraj KumarAmudhan
Ranch Hand

Joined: Aug 22, 2009
Posts: 110
thank you sir!
yuvaraj KumarAmudhan
Ranch Hand

Joined: Aug 22, 2009
Posts: 110
sorry for disturbing you again sir!



/Template Viewer/GetFile ---> This links the servlet and servlet calls a method in DAO layer.
That method gets the "css content as String" (String! not a css file) from the database and return that string to the servlet.

Finally 'the css content comes as String" in servlet.

'href' attribute of 'link' tag links only the css file i think(Not the string).

still confused!

thank you!


Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Set the content type of text/css of the string being returned. It does not care how the CSS file is generated on the server.

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: storing the responseText into a file
 
Similar Threads
Ajax: ResponseXML is getting null
Ajax Suggest
Ajax: ResponseXML is getting null
AJAX responseText as pdf
HTML to Text via Screen scrape