Hi Martin,
I tried your sample for downloading a file. Its working fine and its very
useful for us. Thank you very much for your help.
In your sample you've used a setHeader name as "Content-Disposition" in
response.setHeader("Content-Disposition","inline;filename="+filename);
As Iam new to Servlets can you tell me where I can get info regarding the
different types of setHeader names.
Thank you for spending your time.
-Ravi.
>From: Martin Kuba <[EMAIL PROTECTED]>
>Reply-To: "A mailing list for discussion about Sun Microsystem's Java
> Servlet API Technology." <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: File downloading in Servlets.
>Date: Wed, 28 Jul 1999 09:28:43 +0200
>
>Ravi T wrote:
> >
> > Hi,
> >
> > Iam using Servlets for our Server side programming. In one of our web
>pages
> > we've to allow the user to, save the data that he entered on the browser
> > into a file in his system(client machine). Can anyone suggest me the way
>for
> > coding in the Servlets.
> >
> > Thank you,
> > Ravi.
>
>This is my solution. I have tried it with MSIE 3,4,5 and Netscape 4 :
>--------------------------------------------------------------------------------
>import java.io.*;
>import java.util.*;
>import java.text.*;
>
>import javax.servlet.*;
>import javax.servlet.http.*;
>
>public class Uloz extends HttpServlet
>{
> public void doGet (HttpServletRequest request,
> HttpServletResponse response)
> throws ServletException, IOException
> {
> String filename = "myfilename";
> PrintWriter out;
> if(request.getHeader("user-agent").indexOf("MSIE")!= -1)
> {
> response.setContentType("application/x-muj-typ");
> response.setHeader("Content-Disposition","inline;filename="+filename);
> }
> else
> {
> response.setContentType("application/octet-stream");
>
>response.setHeader("Content-Disposition","inline;filename="+filename+".txt");
> }
> out = response.getWriter();
> try {
> //-----
> out.println("Your data: \""+request.getParameter("kod")+"\"");
> //-----
> } catch (Exception ex)
>{out.println(ex.getMessage());ex.printStackTrace(out);}
> }
>
>}
>--------------------------------------------------------------------------------
>Martin
>--
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> INET, a.s. Mgr. Martin Kuba
>Kralovopolska 139 e-mail: [EMAIL PROTECTED]
> 601 12 Brno WWW: http://www.inet.cz/~makub/
> Czech Republic tel: +420-5-41242414/33
>--------------------------------------------------------------------
>PGP fingerprint = D8 57 47 E5 36 D2 C1 A1 C3 48 B2 59 00 58 42 27
> http://wwwkeys.cz.pgp.net:11371/pks/lookup?op=index&search=makub
>--------------------------------------------------------------------
>
>___________________________________________________________________________
>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
>
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
___________________________________________________________________________
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