Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Create a CSV file in the local system dynamically  RSS feed

 
Sanjay Krishna Bitra
Greenhorn
Posts: 6
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to create a CSV file dynamically in the user's system whoever uses my Application so that I can write data into it and then import it to an Excel.

Once I am done with my Application, I am deploying the WAR file in the Tomcat Server in the Server system. I am trying to use System.getProperty("user.home") for creating the file in a particular path. But the file is creating in the system where the App is deployed (Server system).

Different users will be using the App in different systems,so how can I get the path for creating a file in the Local Host System (user's system)?

Any help will be appreciated.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A web app can't access the client file system. You'll have to store the file somewhere on the server file system and provide a link to download it, or stream the CSV directly to the browser.
 
Sanjay Krishna Bitra
Greenhorn
Posts: 6
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:A web app can't access the client file system. You'll have to store the file somewhere on the server file system and provide a link to download it, or stream the CSV directly to the browser.


Thanks Dittmer. I hope, this will help me out. Actually, I want to write the data into CSV and then import the data into Excel Workbook. Can you explain me, how to stream CSV to browser?
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When your web application gets a request for the CSV file data, simply write that data to the response.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36463
462
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see the word "servlet" anywhere in this thread, so added it. You need to return the CVS via the HttpResponse of a servlet.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!