This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Servlets and the fly likes How to dowload dynamic  .csv file from server without creating a copy in server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "How to dowload dynamic  .csv file from server without creating a copy in server" Watch "How to dowload dynamic  .csv file from server without creating a copy in server" New topic
Author

How to dowload dynamic .csv file from server without creating a copy in server

Devapatla Ramagopal Reddy
Greenhorn

Joined: Aug 14, 2001
Posts: 5
Hi All,
I do hav some problem, i want to write a servlet for download, dynamically created .csv file to the local system, the servlet works fine, but it retains a copy in server also, i am using weblogic server.
Here is my code snnipitts of my servlet , i want to download the file to local system, with out creating a copy in my server.
File csvFile;
FileOutputStream file;
//codes to generate a file in local server for downloading
Calendar calendar = Calendar.getInstance();
String strFileName = Integer.toString(calendar.get(Calendar.YEAR))+Integer.toString(calendar.get(Calendar.MONTH))+Integer.toString(calendar.get(Calendar.DATE))+Integer.toString(calendar.get(Calendar.HO UR))+Integer.toString(calendar.get(Calendar.MINUTE))+Integer.toString(calendar.get(Calendar.SECOND))+Integer.toString(calendar.get(Calendar.MILLISECOND));
try {
strFileName = DeformatAcctNo(req.getParameter("acct_trxn__acctselected")) + strFileName + ".csv";
} catch (Exception e) {}
calendar = null;
csvFile = new File(strFileName);
if (!csvFile.exists()) {
csvFile.createNewFile();
}
file = new FileOutputStream(csvFile);res.setContentType("application/download");
res.setHeader("Content-Disposition","attachment;filename=" + strFileName);
javax.servlet.ServletOutputStream servletoutputstream1 = res.getOutputStream();
String s = strFileName;

dumpFile(s, servletoutputstream1);
servletoutputstream1.flush();
servletoutputstream1.close();
Any help much aprreciated....
Thanx in advance....
Ram.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to dowload dynamic .csv file from server without creating a copy in server