Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Servlet Interest »

Re: Download on click of a link

Qin Ke

2003-11-27

Replies:

Hi you can try this code snipplet for the stream :

  java.io.FileInputStream FIS = new java.io.FileInputStream(filepath);
  java.io.BufferedInputStream bis = new java.io.BufferedInputStream(FIS);
  PrintWriter out = response.getWriter();

 int i;

  while ((i=bis.read()) != -1)
 {
  out.write(i);
 }

 FIS.close();

 bis.close();

And befor the stream you should set the special http
header:Content-Disposition.


                                            Qin Ke




----- Original Message -----
From: "Karthikeyan" <karthik@(protected)>
To: <SERVLET-INTEREST@(protected)>
Sent: Thursday, November 27, 2003 10:14 PM
Subject: Re: Download on click of a link


> yes. We r trying in that line, but we couldnt make any headway.
> code snipplet for the streaming part will help us.
>
> -----Original Message-----
> From: A mailing list for discussion about Sun Microsystem's Java Servlet
> API Technology. [mailto:SERVLET-INTEREST@(protected)
> Jean-Christophe CHARVY
> Sent: Thursday, November 27, 2003 6:35 PM
> To: SERVLET-INTEREST@(protected)
> Subject: Re: Download on click of a link
>
>
> Hi all folks,
>
> What you want to do, can be solved with a servlet.
> You can invoke a servlet in a link, by passing parameters in the URL.
> (http://mydomain/myservlet?param1=42397&param2=inline, for example)
>
> This servlet has just to build a stream on the response and write in this
> stream the octets table which represents the file to be
> downloaded (with the special header, as Veerendra Jote has told you).
>
> This has been explained in this list a few months ago. Search the archives
> ...
>
>
> > Message du 27/11/03 à 12h26
> > De : Mr. Cristian D. Romanescu <c.romanescu@(protected)>
> > A : SERVLET-INTEREST@(protected)
> > Copie à :
> > Objet : Re: Download on click of a link
> >
> > IMHO I think that is not possible. In IE for example you could have a
> > download manager which listens to links and when I press the link to a
> > file (exe, zip etc) it starts download program.
> > Maybe it will be possible by installing an signed ActiveX or such in IE
> > (as for example macromedia flash does) but again in Mozilla you can't do
> > that...
> >
> > c.
> >
> >
> > Karthikeyan wrote:
> >
> > >Hi.,
> > >
> > >I hava a problem.
> > >
> > >I have a link in my page. On click of it, it is showing a dialog that
> asks
> > >for Save As or Run. I need to avoid that and want the downloadable to
> > >install directly on click of the link.
> > >
> > >Thanks.
> > >
> > >Karthik.S
> > >
> > >
> > >
> >
>
>___________________________________________________________________________
> > >To unsubscribe, send email to listserv@(protected)
> 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
> > >
> > >
> > >
> > >
> >
> > --
> > ======================================
> > Cristian Romanescu
> >
> > Tecnico Junior
> > Finsiel Romania srl
> >
> > Mobile: +40745133096
> > Web         : http://www.geocities.com/ext007
> >
> > Fools ignore complexity; pragmatists suffer it; experts avoid it;
geniuses
> remove it. ~A. Perlis
> >
> >
>
___________________________________________________________________________
> > To unsubscribe, send email to listserv@(protected)
> 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
> >
> ------------------------------------------
>
> Faites un voeu et puis Voila ! www.voila.fr
>
>
___________________________________________________________________________
> To unsubscribe, send email to listserv@(protected)
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
>
>
___________________________________________________________________________
> To unsubscribe, send email to listserv@(protected)
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
>
>

___________________________________________________________________________
To unsubscribe, send email to listserv@(protected)
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


©2008 junlu.com - Jax Systems, LLC, U.S.A.