M
Madni
Hi .
I am trying to send csv file from server to client , i can see the
dialog which can be used to save the file on the specific location on
the client side ... but no information is sent and file is saved with 0
bytes ... can any one please guide me in this ...
Here is the chunk of code using which i am trying to send csv ...
System.out.println("before setting contenttype "); // this statement
always gets printed
httpservletresponse.setContentType( "application/csv");
System.out.println("after setting contenttype ");// this statement
never gets displayed
httpservletresponse.setHeader("Content-Disposition","inline;
filename=" +strtemp[1]+".csv" );
try {
File uFile = new File(strFilePath);
int fSize = (int) uFile.length();
FileInputStream fis = new
FileInputStream(uFile);
PrintWriter pw =
httpservletresponse.getWriter();
int c = -1;
while ( (c = fis.read()) != -1) {
pw.print( (char) c);
}
// Close output and input resources.
fis.close();
pw.flush();
pw = null;
}
catch (Exception e) {
System.out.println("Exception is caught
");
e.printStackTrace();
}
I am trying to send csv file from server to client , i can see the
dialog which can be used to save the file on the specific location on
the client side ... but no information is sent and file is saved with 0
bytes ... can any one please guide me in this ...
Here is the chunk of code using which i am trying to send csv ...
System.out.println("before setting contenttype "); // this statement
always gets printed
httpservletresponse.setContentType( "application/csv");
System.out.println("after setting contenttype ");// this statement
never gets displayed
httpservletresponse.setHeader("Content-Disposition","inline;
filename=" +strtemp[1]+".csv" );
try {
File uFile = new File(strFilePath);
int fSize = (int) uFile.length();
FileInputStream fis = new
FileInputStream(uFile);
PrintWriter pw =
httpservletresponse.getWriter();
int c = -1;
while ( (c = fis.read()) != -1) {
pw.print( (char) c);
}
// Close output and input resources.
fis.close();
pw.flush();
pw = null;
}
catch (Exception e) {
System.out.println("Exception is caught
");
e.printStackTrace();
}