C
coolsboy
Unregistered / Unconfirmed
GUEST, unregistred user!
HTML :fileDownLoad.htm
<html>
<head>
<title>Untitleddo
cument</title>
<meta http-equiv="Content-Type" content="text/html;
charset=Shift_JIS">
</head>
<body bgcolor="#FFFFFF" text="#000000" >
<FORM method="POST" name="f1" action="/yki/servlet/yki.E050_DownLoad">
<center>
<input type="submit" name="e050_logDo_flg" value="login" >
</center>
</FORM>
</body>
</html>
<-------------------------------------------------------->
servlet :E050_DownLoad.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class E050_DownLoad extends HttpServlet implements Constants{
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException{
HttpServletResponse m_response = response;
String filename = "import_error_list";
String filetype = ".txt";
String sourceFilePathName = "C:/kura/"+filename + filetype;
File file = new File(sourceFilePathName);
/*if(!file.exists()){
out.println("filedo
nnot exist");
out.flush();
out.close();
return;
}*/
FileInputStream fileIn = new FileInputStream(file);
long fileLen = file.length();
int readBytes = 0;
int totalRead = 0;
byte b[] = new byte[65000];
110 m_response.setContentType("application/x-msdownload");
m_response.setContentLength((int)fileLen);
String contentDisposition = "attachment;";
m_response.setHeader("Content-Disposition", String.valueOf((new StringBuffer(String.valueOf(contentDisposition))).append(" filename=").append(filename + filetype)));
while((long)totalRead < fileLen)
{
readBytes = fileIn.read(b, 0, 65000);
totalRead += readBytes;
m_response.getOutputStream().write(b, 0, readBytes);
}
fileIn.close();
}
}
//******************************************
when choose "save" ,always HTML page(fileDownLoad.htm) isdo
wnloaded.
but when choose "open" , it is right,import_error_list.txt is opened in the HTML page.
why?ido
nnot know.
else
if 11O line is so : m_response.setContentType("application/zip");
then
: first when choose "save" , HTML page(fileDownLoad.htm) isdo
wnloaded.
if select open then
message windows change to "E050_DownLoad isdo
wnload" be asked;
if select save then
right result: import_error_list.txt can bedo
wnloaded;
How should Ido
?
help.
than
<html>
<head>
<title>Untitleddo
cument</title>
<meta http-equiv="Content-Type" content="text/html;
charset=Shift_JIS">
</head>
<body bgcolor="#FFFFFF" text="#000000" >
<FORM method="POST" name="f1" action="/yki/servlet/yki.E050_DownLoad">
<center>
<input type="submit" name="e050_logDo_flg" value="login" >
</center>
</FORM>
</body>
</html>
<-------------------------------------------------------->
servlet :E050_DownLoad.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class E050_DownLoad extends HttpServlet implements Constants{
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException{
HttpServletResponse m_response = response;
String filename = "import_error_list";
String filetype = ".txt";
String sourceFilePathName = "C:/kura/"+filename + filetype;
File file = new File(sourceFilePathName);
/*if(!file.exists()){
out.println("filedo
nnot exist");
out.flush();
out.close();
return;
}*/
FileInputStream fileIn = new FileInputStream(file);
long fileLen = file.length();
int readBytes = 0;
int totalRead = 0;
byte b[] = new byte[65000];
110 m_response.setContentType("application/x-msdownload");
m_response.setContentLength((int)fileLen);
String contentDisposition = "attachment;";
m_response.setHeader("Content-Disposition", String.valueOf((new StringBuffer(String.valueOf(contentDisposition))).append(" filename=").append(filename + filetype)));
while((long)totalRead < fileLen)
{
readBytes = fileIn.read(b, 0, 65000);
totalRead += readBytes;
m_response.getOutputStream().write(b, 0, readBytes);
}
fileIn.close();
}
}
//******************************************
when choose "save" ,always HTML page(fileDownLoad.htm) isdo
wnloaded.
but when choose "open" , it is right,import_error_list.txt is opened in the HTML page.
why?ido
nnot know.
else
if 11O line is so : m_response.setContentType("application/zip");
then
: first when choose "save" , HTML page(fileDownLoad.htm) isdo
wnloaded.
if select open then
message windows change to "E050_DownLoad isdo
wnload" be asked;
if select save then
right result: import_error_list.txt can bedo
wnloaded;
How should Ido
?
help.
than