[opencms-dev] Setting manual Content-Type header from a jsp
Stephan Hartmann
hartmann at metamesh.de
Mon Jun 15 23:01:04 CEST 2009
Hi Mike,
the reason why your attempts for setting the content type by either
using the response object or the contentType attribute in the page
directive is that the JSP is usually embedded by using the include
dispatcher of the request. From within an included webapp resource
(either servlet or JSP or filter) there is no way to modify response
headers, as defined in the servlet spec.
For your case, it would be sufficent to set the cache property of your
JSP to "bypass" which will lead to a forward instead of an include, what
will give you control over your response headers as well. Note that you
will lose flex cache functionality with that property set.
Another way to set response headers from an included JSP would be to get
hold of the top response object through the CmsFlexController object of
your request.
Regards,
Stephan
Mike Dikan schrieb:
> I have need for a jsp that spits out dynamic javascript called
> something like javascript_dynamic_variable_init.jsp. In opencms, if
> you have a file on the vfs that has extension .js, the content-type
> header that is returned is of type 'application/x-javascript', and if
> you have a file that ends in extension .jsp, the content-type header
> is 'text/html'. I need to change the content-type header returned for
> a file ending in .jsp to the .js header, but any attempts to do so
> either by using the <%@page contentType="" %> tag, or operating on the
> response directly is clobbered by opencms. Does anyone know how to do
> this in opencms 7.0.5?
>
> And to head off any questions, i can't rename the file to .js, because
> the file needs to be brought in as a jsp opencms 'type' via the
> synchronize functionality, which will only create types based on file
> extensions, as far as I know.
>
> Thanks!
> -Mike
>
> _______________________________________________
> 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
>
>
More information about the opencms-dev
mailing list