When cancel download, Explorer window is closed.

S

Son KwonNam

I made a download JSP page and it works fine mostly.
But *SOMETIMES* when a IE download dialog is open, if a user click
cancel/save download button, the IE window which contains download link
*CLOSED* suddenly.

Users said it only happens when they use my sites. No problems with
other sites' download.

Any solution?

Regards,
KwonNam.

The following is the source code of download jsp.
----
<%
/**
* @author trypsr
*/
%><%@ page language="java" contentType="application/octet-stream;
charset=iso-8859-1"
import="java.io.*,
java.util.*,
java.text.*,
java.net.*,
com.datec.main.Props"
%><%
request.setCharacterEncoding("euc-kr");
String doFlag = request.getParameter("doFlag");
String filename = request.getParameter("filename");

String id = request.getParameter("id");
int filesize = 0;

String path = "";

if(doFlag.equals("fullText")){
path = Props.getInfo("LawInfo", "lawUpload");
}else if(doFlag.equals("compare")){
path = Props.getInfo("LawInfo", "compareUpload");
}else if(doFlag.equals("appendix")){
path = Props.getInfo("LawInfo", "appendixUpload");
}

String filePath = path + filename;
java.io.File sz = new File(filePath);
filesize = (int)sz.length();
if(doFlag.equals("compare")){
filename=
filename.substring(filename.lastIndexOf(java.io.File.separator)+1,
filename.lastIndexOf('.')-1)
+"_compare"+filename.substring(filename.lastIndexOf('.'),
filename.length());
}else{
filename=
filename.substring(filename.lastIndexOf(java.io.File.separator)+1,
filename.length());
}
response.setContentType("application/octet-stream; ");

int len = Math.min(15, filename.length());
if(len!=filename.length()) filename =
filename.substring(filename.length()-15, filename.length());

response.setHeader("Content-Disposition", "attachment; filename=\""
+ java.net.URLEncoder.encode(filename) + "\"" );
response.setHeader("Content-Transfer-Encoding", "7bit");
response.setHeader("Content-Length", filesize+"");

byte b[] = new byte[filesize];
ServletOutputStream fout = response.getOutputStream();

try{
File f = new File(filePath);
FileInputStream fin = new FileInputStream(f);

fin.read(b);
fout.write(b,0, b.length);
}catch(java.io.FileNotFoundException e){
e.printStackTrace();
}finally{
fout.close();
}
%>
 
C

Chris Smith

Son KwonNam said:
I made a download JSP page and it works fine mostly.
But *SOMETIMES* when a IE download dialog is open, if a user click
cancel/save download button, the IE window which contains download link
*CLOSED* suddenly.

Users said it only happens when they use my sites. No problems with
other sites' download.

Any solution?

I don't have an answer to your specific question, but allow me to
suggest that you learn about servlets. Using a JSP for this is
equivalent to using a cheese-grater to eat spaghetti. The result is
difficult for us to read, and difficult for you to maintain.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
S

Son KwonNam

We've finally solved this problem.
I think it is a bug of IE 6.0 of Windows XP SP2.
It only happens of IE 6.0 of Windows XP SP2.

Anyway, when we link download files with <A> tag,
just put "target='_top'".

Disappearing windows does not happen any more.

Regards,
KwonNam.

Son KwonNam ¾´ ±Û:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,871
Messages
2,569,919
Members
46,172
Latest member
JamisonPat

Latest Threads

Top