[opencms-dev] response.setContentType()

Olli Aro olli_aro at yahoo.co.uk
Thu Nov 16 15:42:26 CET 2006


You could try to rename your actual jsp to .gif. That has sometimes done the
trick for me :) You also might have to set the setContentType for the
request that you get from the cmsobj.getRequestContext().

Olli

-----Original Message-----
From: opencms-dev-bounces at opencms.org
[mailto:opencms-dev-bounces at opencms.org] On Behalf Of SCHEDENIG Marian
Sent: 16 November 2006 14:31
To: opencms-dev at opencms.org
Subject: [opencms-dev] response.setContentType()

Hi!

I'm trying to manually stream binary data to the client from within a
JSP. The idea is to send images from the VFS so I can set the attachment
mode to "inline", in which case most browsers show a dialog asking the
user where to save the image data.

My problem is that response.setContentType() seems to have no effect.
When reading the content type from the response right after the set
command, I still get "text/html".

Is there any way to do this without writing a full servlet?

My test code (without the attachment type) looks like this:


<%@ page session="false" import="java.io.*, org.opencms.jsp.*,
org.opencms.file.*, javax.servlet.*" %>
<%
    response.setContentType("image/gif");
    CmsObject cmsobj = new CmsJspActionElement(pageContext, request,
response).getCmsObject();
    CmsFile fout =
cmsobj.readFile("/Josefstadt_Gallery/Bilder_Allgemein/Sitzplan_Josefstad
t.gif");
    byte[] bytes=fout.getContents();
    response.setContentLength(bytes.length);
    ServletOutputStream sout = response.getOutputStream();
    sout.write(bytes);
    sout.flush();
    response.flushBuffer();
%>


Thx,
Marian.

_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev


-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.430 / Virus Database: 268.14.5/534 - Release Date: 14/11/2006
15:58


Send instant messages to your online friends http://uk.messenger.yahoo.com 



More information about the opencms-dev mailing list