Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CREATING FILE FROM SERVLET

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a servlet which throws an HTML page with a button "Save this page as Text". If the user clicks on the button, I want to create a file in the user's computer and write some data.
How do I achieve this?
 
Jesse Tilly
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A couple of ways. The button could trigger JavaScript that requests a file you've created server-side. The user will be asked if it's okay to save/run it. The button could also POST to a servlet that "responds" as a file rather than as HTML. The browser will handle it according to its MIME settings. Or, the button could trigger JavaScript that makes the servlet request generating a dynamic filestream (no messy temp files).
Jesse
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankx for your prompt reply.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic