aspose file tools*
The moose likes Servlets and the fly likes file down loading(very very urgent) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "file down loading(very very urgent)" Watch "file down loading(very very urgent)" New topic

file down loading(very very urgent)

kalyan kiran

Joined: Aug 21, 2001
Posts: 5
I Want to know whether a file is properly downloaded or not
at client side from server and also i would like to know how many bytes are being downloaded and i wil be very happy if any one of u can give me a sample code for downloading a file,
my client side is html page and middle tier is a servelt .pls reply me immediately
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
hope this helps...
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.util.*;
public class DownloadFile2 extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException{
ServletOutputStream sos = null;
BufferedInputStream bis = null;
/*String id_usuario = request.getParameter("id_usuario");
String id_carpeta = request.getParameter("id_carpeta");
String ruta_objeto = request.getParameter("ruta_objeto");
File f = new File(FILE_PATH);
response.setHeader("Content-Disposition","attachment;filename="+ f.getName());
bis = new BufferedInputStream( new FileInputStream(f));
byte buffer2[] = new byte[bis.available()];, 0, buffer2.length);
sos = response.getOutputStream();
sos.write(buffer2, 0, buffer2.length);
good luck.
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
...of course dont forget to call DownloadFile2
via a submit button in a form:
<form action=\"http://localhost:8080/servlet/DownloadFile2\" enctype=\"multipart/form-data\" method=get>
<input type=submit>
I agree. Here's the link:
subject: file down loading(very very urgent)
Similar Threads
putting Applet jar in client browser
question about downloading
copying file from client system to and storing in server
Edit Server side word file using java --- vikas
Compressing JSP on web server and Uncompressing at client browser