Hello Sean,

This saves me from a  lot of work.Tnanx. I just tried it and it works fine,
except for the case of  of images. I guess for that case I have to use
ContentType("image/jpeg").

Konstantina


----- Original Message -----
From: "Sean Willson" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Friday, March 15, 2002 1:59 AM
Subject: Re: Downloading files


> Try this:
>
>    // get the file extension
>    String fileName = formFile.getFileName();
>    // the mime type for this file
>    String mimeType = servlet.getServletContext().getMimeType(fileName);
>    // if we got one set it
>    if (null != mimeType) {
>      response.setContentType(mimeType);
>    }
>    // otherwise set a default
>    else {
>      response.setContentType("text/plain");
>    }
>
>    // otherwise output the file
>    ServletOutputStream os = response.getOutputStream();
>    os.write(formFile.getFileData());
>    return null;
>
> Works for us ... This way you leave it up to the container to tell you
> the mime type. You can also configure mime types in your web.xml
> deployment descriptor file.
>
> Sean
>
> Konstantina Stamopoulou wrote:
> > Hi Alexander,
> >
> > This is what I did after searching the archieves. I'm a little bit
confused
> > with the mime type (shouldn't "multipart/form-data " work for every type
of
> > file? it doesn't work for .jsps). I think I have to search more on this
> > one.
> >
> > Thanx for the reply,
> > Konstantina
> >
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to