On 02.11.10 16:32, Markus Pielmeier markus.pielme...@googlemail.com
wrote:
Hi,
I'm currently implementing some JSP pages for my Sling components. How
can I define a specific HTTP response content type for my dynamic JSP
pages? I want my page to be delivered with text/css MIME type.
I've created a new component my_component. Below MyComponent I've
added a JSP with the name my_component.css.jsp. my_component.css.jsp
has the following content:
---snip---
%...@page contentType=text/css; charset=utf-8%
.my_demo_css {
/* further dynamic CSS code comes here */
}
---snip---
I can access my component with a URL like
http://localhost:4502/.../my_content.css. But the HTTP response from
Sling is delivered with a text/html content type.
Generally I'm not sure how Sling determines the response content type
for a delivered page. When I understand the documentation [1] right
then Sling uses the file extension to determine the MIME type for the
content type? But which extension is meant here? Is it the file
extension of the URL? Or is it the extension of my files in the JCR?
No, this mime type setting should only apply if a binary file is directly
streamed from the repository (using sling's fallback webdav servlet), but
not if this is a node with a resource type that is rendered using a jsp
script. In that case the jsp defines the content type of the response.
I've also tries to set the content type in the JSP manually:
---snip---
% response.setContentType(text/css; charset=utf-8); %
---snip---
This doesen't work either.
Both the @page directive and the response.setContentType() should work.
Are you sure you inspected that using a tool like curl? I remember
browsers sometimes showing text/html for all text files if you view them
directly in the browser...
To me it seems like (maybe Sling)
overwrites the content type after my JSP is fully rendered. Can this
be the case?
I don't think so...
Regards,
Alex
--
Alexander Klimetschek
Developer // Adobe (Day) // Berlin - Basel