[opencms-dev] Setting manual Content-Type header from a jsp
Mike Dikan
dikeman at gmail.com
Tue Jun 16 00:19:30 CEST 2009
Sorry, just found the static CmsFlexController.getController(request)
method to answer the first part of my last email.
As for the second part, I attempted this:
HttpServletResponse topLevelResponse =
CmsFlexController.getController(request).getTopResponse();
But calls to modify the headers on topLevelResponse don't seem to be
taking effect.
Any pointers?
-Mike
On Jun 15, 2009, at 5:01 PM, Stephan Hartmann wrote:
> 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
>>
>>
>
>
> _______________________________________________
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20090615/4d3b3186/attachment.htm>
More information about the opencms-dev
mailing list