[opencms-dev] Can not override mimetype from jsp

Paul-Inge Flakstad flakstad at npolar.no
Fri May 24 11:10:14 CEST 2013


Hi Yves,

Try calling CmsJspActionElement.setContentType(java.lang.String) as well. I see I’ve used that method in my similar JSPs, and they work like they should.

HTH :)

Cheers,
Paul

From: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Yves Glodt
Sent: 24. mai 2013 11:03
To: The OpenCms mailing list
Subject: [opencms-dev] Can not override mimetype from jsp

Hello,

I have a JSP which reads a file from the local filesystem (not the vfs) and outputs it to the browser.

But the content-type I set is not taken into account. Whatever I tried the browser always gets text/html as content-type. Does OpenCms override it ?




Here is a code fragment:


            ServletOutputStream outStream=response.getOutputStream();
            File myfile = new File("/mnt/data/"+filename);
            FileInputStream input = new FileInputStream(myfile);

            System.out.println(request.getRemoteAddr() + ": Size: " + myfile.length());

            response.setContentType("application/pdf");
            response.setHeader("Content-Disposition","inline;filename=" + name);
            response.setContentLength( (int) myfile.length() );


            int readBytes = 0;
            while((readBytes = buf.read()) != -1) {
                        outStream.write(readBytes);
            }
            outStream.flush();
            outStream.close();
            buf.close();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20130524/70d1e162/attachment.htm>


More information about the opencms-dev mailing list