Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

Devapatla Ramagopal Reddy
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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()) {
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);
Any help much aprreciated....
Thanx in advance....
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic