The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

file downloading

Posted by Oliver on November 15, 2000 at 12:44 AM

> I had written following Java Download Servlet and which is working fine with Netscape but not with Internet Explorer. Problem with Internet Explorer is that while Downloading file, Instead of taking File Name it takes Servlet Name for file Downloading...
> Any body has any clue, where I am wrong in this??

> Thank you very much in advance.

> bhaskar

> import java.io.*;
> import java.util.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.sql.*;

> public class fileDownload extends HttpServlet {

> public void doGet(HttpServletRequest req ,HttpServletResponse res)
> throws IOException,ServletException {
> try{
> doPost(req,res);
> }catch(Exception e){e.printStackTrace();}
> }

> public void doPost(HttpServletRequest req ,HttpServletResponse res)
> throws IOException,ServletException {

> res.setContentType("application/x-filler");
> HttpSession session = req.getSession(true);

> try {
> String fileName= req.getParameter("filename");
> String filePath = req.getParameter("filepath");
> String downloadFile = filePath + fileName;
> //String userName = (String) session.getValue("login_name");
> String download_date = "sysdate";

> res.setHeader("Content-Disposition","attachment; filename=\"" + downloadFile + "\";");

> ServletOutputStream stream = res.getOutputStream();

> BufferedInputStream fif = new BufferedInputStream(new FileInputStream(downloadFile));
> int data;
> while((data = fif.read()) != -1)
> {
> stream.write(data);
> }
> fif.close();
> stream.close();
> }

> catch(Exception e) {
> e.printStackTrace();
> }

> finally {
> try{

> } catch (Exception ignore) {}
> }

> }
> }


Hi krnbhaskar,

I have got the same problem! I think it is not a general problem with the Internet Explorer. In my opinion it is a special problem with the Internet Explorer 5.5 SP1. With other Versions it seems to work fine.

Nevertheless I was not able to solve this problem! Has anybody a solution?

regards Oliver



Replies:
  • tyeyey etyety February 13, 2001 at 6:41 AM (0)

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us