Hi Hilz,

find below the corresponding JSP-page from the MyFaces-examples.

regards,

Martin

<%@ page import="java.io.File,
                 java.io.InputStream,
                 java.io.FileInputStream,
                 java.io.OutputStream"%><%@ page session="false" %><%
    String contentType = (String)application.getAttribute("fileupload_type");
    String fileName = (String)application.getAttribute("fileupload_name");

    String allowCache = request.getParameter("allowCache");
    String openDirectly = request.getParameter("openDirectly");

    if(allowCache == null || allowCache.equalsIgnoreCase("false"))
    {
        response.setHeader("pragma", "no-cache");
        response.setHeader("Cache-control", "no-cache, no-store,
must-revalidate");
        response.setHeader("Expires", "01 Apr 1995 01:10:10 GMT");
    }

    if(contentType!=null)
    {
        response.setContentType(contentType);
    }

    if(fileName != null)
    {
        fileName = fileName.substring(fileName.lastIndexOf('\\')+1);
        fileName = fileName.substring(fileName.lastIndexOf('/')+1);

        StringBuffer contentDisposition = new StringBuffer();

        if(openDirectly==null || openDirectly.equalsIgnoreCase("false"))
        {
            contentDisposition.append("attachment;");
        }

        contentDisposition.append("filename=\"");
        contentDisposition.append(fileName);
        contentDisposition.append("\"");

        response.setHeader ("Content-Disposition",
contentDisposition.toString());
    }

    byte[] bytes = (byte[])application.getAttribute("fileupload_bytes");
    if (bytes != null)
    {
        response.getOutputStream().write(bytes);
    }



On 12/4/05, hilz <[EMAIL PROTECTED]> wrote:
> Martin Marinschek wrote:
> > You need to change the content-disposition header to "attachment", I think.
> >
> > There is a MyFaces example which shows how to do this!
> >
> > regards,
> >
> > Martin
> >
>
>
> Hi Martin,
> Thank you for your answer.
> I tried to search for that, but could not find anything that would solve
> my problem.
> Would you please be kind enough and provide me with a link or something
> of the sort....
> I am kind of new to this area and would appreciate any help.
> thanks
>
> Hilz
>
>


--

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Reply via email to