hello Sunil,

What I could suggest you to do is that on the click of  a button you may call a
servlet which downloads a file. And in this case you even not put the file in
the public_html directory..... The servlet could look something like this...

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class DownloadServlet extends HttpServlet {

 public void service(HttpServletRequest req,HttpServletResponse res) throws
ServletException, IOException
 {
     res.setContentType("application/x-filler");
     res.setHeader("Content-Disposition","attachment; filename=out.fif;");
     ServletOutputStream stream = res.getOutputStream();
     BufferedInputStream fif = new BufferedInputStream(new
FileInputStream("d:\\in.fif"));
// At the above path you could specify the file to be downloaded.....
     int data;
     while((data = fif.read()) != -1) {
         stream.write(data);
     }
     fif.close();
     stream.close();
   }
  }


Hope it helps...

Vikram

Sunil Chinjwani wrote:

> I have a ( .csv) file on the server. I want to transfer the file to the
> client machine when he clicks on a anchor or a button..........
> There is one option of providing a direct link like this :
> <a href="filename">
> But I cannot do this bcoz I would have to place the file in public-html.
>
> The file is a personal one,say the addressbook (.csv file), so if I keep
> it in public html it will be accessible to all.....
> Is there some way we can trasfer the file from the server to the client
> machine without putting the file in public html ??????????????????/
> Please help, urgent requirement...................
>
> Sunil...........
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

--
Vikram Kumar

************************************
No God-No Peace. Know God-Know Peace
************************************

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to