• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

storing the responseText into a file

 
yuvaraj KumarAmudhan
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you sir!
 
yuvaraj KumarAmudhan
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic