Ok, I see now.
If a custom weblet calls
response.setContentType("foo")
it gets "foo".
If a custom weblet calls
response.setContentType(null)
then it gets the container default.
But if it never calls
response.setContentType
then it gets no "Content-Type" header at all.
It seems rather odd to have to add a call of
response.setContentType(null)
to my code in order to *get* a content-type output...
But thanks very much for clearing that up.
Regards,
Simon
Werner Punz schrieb:
> Hello Simon
>
> The mimetype is set
> from the container itself via the mime type apis.
>
> Usually the content type is added at the outer rim of
the system
> (aka servlet, phase listener) when the response object
is generated
> String contentName = webRequest.getPathInfo();
> String contentTypeDefault =
> getServletContext().getMimeType(contentName);
> WebletResponse webResponse =
> new WebletResponseImpl(contentTypeDefault,
httpResponse);
> _webletContainer.service(webRequest,
webResponse);
>
> You can enforce different mime types by altering the
content type
> attribute in the weblet response
> from your own weblet.
> The probably more generic and more neutral way is to
set your file
> extensions in your
> paths according to the mime type the container expects
for your dynamic file.
>
> Weblet currently does not have its own mimetype
mappings
> (although there is some pre 0.4 code in there which
prepares such a
> subsystem, it
> might make sense to readd it again later because some
containers do not deliver
> mimetype lists on default)
>
>
>
> Werner
>
>
>
>
>
> On Wed, May 14, 2008 at 4:38 PM, simon.kitching chello.at
> <simon.kitching chello.at> wrote:
>
>> I'm confused.
>>
>> The resources that are served up by my custom
weblet are not getting any
>> Content-Type header.
>>
>> And I've grepped through the entire codebase of
weblets and not found
>> anywhere that is actually setting the content-type
for resources.
>>
>> But somehow the content-type is being set for
resources on the weblets
>> demo site:
>> http://confe
rence.irian.at/weblets-demo/
>> For example the "a simple weblet include via a
jsp bean" page when
>> tested with Firefox + LiveHttpHeaders shows the
correct Content-Types
>> for the various files served.
>>
>> Can someone explain how the demo app is getting the
right mime-types for
>> its .js, .css, .png etc resources?
>>
>> Thanks,
>> Simon
>>
>>
>>
------------------------------------------------------------
---------
>> To unsubscribe, e-mail: users-unsubscribe weblets.dev.java.net
>> For additional commands, e-mail: users-help weblets.dev.java.net
>>
>>
>>
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: users-unsubscribe weblets.dev.java.net
> For additional commands, e-mail: users-help weblets.dev.java.net
>
>
>
------------------------------------------------------------
---------
To unsubscribe, e-mail: users-unsubscribe weblets.dev.java.net
For additional commands, e-mail: users-help weblets.dev.java.net
|