Bzzt! You miss out on the 10 points being offered for the right answer to
this question. However, you get 150 points for telling him the right thing
to do regardless.

Chances are he's got extraneous newlines being written before the file is
being spooled. However... one wonders why he didn't jsut provide a mapping
to the text file anyway, or if it's not text, why he's using JSP at all
instead of a servlet.

>From: Hardeep Singh <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and
>     reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: downloading of file
>Date: Fri, 16 Feb 2001 16:37:21 +0530
>
>use a servlet instead of jsp since jsp already has content type set before
>coming to ur code. what u say that the client sees the message first is not
>possible.
>
>Hardeep
>
>----- Original Message -----
>From: "Shailendra" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Friday, February 16, 2001 6:56 AM
>Subject: downloading of file
>
>
> > hi
> > can any body will help me in down loadin of file
> > my problem is
> > i am writing folowing code in my jsp
> > it download the Download.jsp file to the client side but server give the
> > error saying
> >
> > java.lang.IllegalStateException: OutputStream is already being used for
>this
> > request
> >
> > code is like that
> > <%
> > response.setContentType("text/plain");
> >
>response.setHeader("Content-Disposition","attachment;filename=file.txt;");
> > InputStream is = null;
> >
> > File f= new File("Download.jsp");
> > FileInputStream fos=new FileInputStream(f);
> > BufferedInputStream o=new BufferedInputStream(fos); file://8k
> > is=o;
> > //... Read InputStream from Database
> > OutputStream os = response.getOutputStream();
> > if (os != null)
> > {
> >    int c;
> >    while ( (c = is.read()) != -1)
> >    {
> >       os.write(c);
> >    }
> >    os.flush();
> >    os.close();
> > }
> > is.close();
> >
> > %>
> >
> > extra to that(downloading of file)
> > i also want that the client shoud have some html page ,when it get
>download
> > dilogbox(first client see the html page saying download will start
> > autometicaly then download start)
> >
> > shailendra


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to