<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"MS Mincho";
panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:"\@MS Mincho";
panose-1:2 2 6 9 4 2 5 8 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Texte de bulles Car";
margin:0cm;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
span.EmailStyle17
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.TextedebullesCar
{mso-style-name:"Texte de bulles Car";
mso-style-priority:99;
mso-style-link:"Texte de bulles";
font-family:"Tahoma","sans-serif";}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="FR" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hey,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">You may also check what is the default mime type for your file extension in WEB-INF/config/opencms-vfs.xml
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">As an example, all files ending with “.html” will always have the “text/html” mime type:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><mimetypes><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">…<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><mimetype extension=".html" type="text/html" /><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">…<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"></mimetypes><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Siegfried Ehret<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">De :</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> opencms-dev-bounces@opencms.org [mailto:opencms-dev-bounces@opencms.org]
<b>De la part de</b> Paul-Inge Flakstad<br>
<b>Envoyé :</b> vendredi 24 mai 2013 11:10<br>
<b>À :</b> The OpenCms mailing list<br>
<b>Objet :</b> Re: [opencms-dev] Can not override mimetype from jsp<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hi Yves,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">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.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">HTH :)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Paul<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">
<a href="mailto:opencms-dev-bounces@opencms.org">opencms-dev-bounces@opencms.org</a> [<a href="mailto:opencms-dev-bounces@opencms.org">mailto:opencms-dev-bounces@opencms.org</a>]
<b>On Behalf Of </b>Yves Glodt<br>
<b>Sent:</b> 24. mai 2013 11:03<br>
<b>To:</b> The OpenCms mailing list<br>
<b>Subject:</b> [opencms-dev] Can not override mimetype from jsp<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span lang="NO-BOK"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span lang="NO-BOK">Hello,<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK">I have a JSP which reads a file from the local filesystem (not the vfs) and outputs it to the browser.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK">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 ?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK">Here is a code fragment:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><o:p> </o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> ServletOutputStream outStream=response.getOutputStream();<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> File myfile = new File("/mnt/data/"+filename);<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> FileInputStream input = new FileInputStream(myfile);<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> System.out.println(request.getRemoteAddr() + ": Size: " + myfile.length());<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> response.setContentType("application/pdf");<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> response.setHeader("Content-Disposition","inline;filename=" + name);<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> response.setContentLength( (int) myfile.length() );<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> int readBytes = 0;<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> while((readBytes = buf.read()) != -1) {<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> outStream.write(readBytes);<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> }<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> outStream.flush();<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> outStream.close();<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> buf.close();<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</body>
</html>