<div dir="ltr">Thanks for the replies so far !<div><br></div><div>@Paul: I added <span class="" style="white-space:pre"> </span>CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response); cms.setContentType((metadata != null) ? metadata.get(Metadata.CONTENT_TYPE) : "application/octet-stream");</div>
<div style>but nothing changed, still text/html</div><div style><br></div><div style>@Siegfried: The download-jsp was called getFile.jsp. I renamed it to download (without any extension) but that did also not help :(</div>
<div><br></div><div><br><div>before: /getFile.jsp?file=/COMMON/bla/2013_02_DE.pdf&name=2013_02_DE.pdf</div><div>after: /download?file=/COMMON/bla/2013_02_DE.pdf&name=2013_02_DE.pdf<br></div></div><div><br></div></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On 24 May 2013 11:19, Siegfried Ehret <span dir="ltr"><<a href="mailto:s.ehret@eurelis.com" target="_blank">s.ehret@eurelis.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="FR" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Hey,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></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
<u></u><u></u></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:<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><mimetypes><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">…<u></u><u></u></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" /><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">…<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"></mimetypes><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Regards,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Siegfried Ehret<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></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""> <a href="mailto:opencms-dev-bounces@opencms.org" target="_blank">opencms-dev-bounces@opencms.org</a> [mailto:<a href="mailto:opencms-dev-bounces@opencms.org" target="_blank">opencms-dev-bounces@opencms.org</a>]
<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<u></u><u></u></span></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Hi Yves,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></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.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">HTH :)<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Cheers,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Paul<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></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" target="_blank">opencms-dev-bounces@opencms.org</a> [<a href="mailto:opencms-dev-bounces@opencms.org" target="_blank">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<u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span lang="NO-BOK"><u></u> <u></u></span></p>
<div>
<p class="MsoNormal"><span lang="NO-BOK">Hello,<u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><u></u> <u></u></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.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><u></u> <u></u></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 ?<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK">Here is a code fragment:<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><u></u> <u></u></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> ServletOutputStream outStream=response.getOutputStream();<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> File myfile = new File("/mnt/data/"+filename);<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> FileInputStream input = new FileInputStream(myfile);<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> System.out.println(request.getRemoteAddr() + ": Size: " + myfile.length());<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> response.setContentType("application/pdf");<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> response.setHeader("Content-Disposition","inline;filename=" + name);<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> response.setContentLength( (int) myfile.length() );<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> int readBytes = 0;<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> while((readBytes = buf.read()) != -1) {<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> outStream.write(readBytes);<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> }<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> outStream.flush();<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> outStream.close();<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="NO-BOK"> buf.close();<u></u><u></u></span></p>
</div>
</div>
</div>
</div></div></div>
</div>
<br>_______________________________________________<br>
This mail is sent to you from the opencms-dev mailing list<br>
To change your list options, or to unsubscribe from the list, please visit<br>
<a href="http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev" target="_blank">http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev</a><br>
<br>
<br>
<br>
<br></blockquote></div><br></div>