users@jersey.java.net

Re: Re: [Jersey] _at_ImplicitProduces and priorities <was> Re: [Jersey] prioritising HTML representations in web applications when using implicit or explicit views

From: Dusan Hornik <dusan.hornik_at_atlassian.com>
Date: Thu, 02 Apr 2009 16:54:14 +1100

Hello

I am trying to use Jersey and velocity template processor to render the
vm pages.
My problem is that the content-type I am getting in response is text/xml
for Webkit browsers (Safari, Chrome).

To reproduce this I created DummTemplateProcessor class in bookstore
1.0.3-SNAPSHOT
---
@Provider
public class DummyTemplateProcessor implements TemplateProcessor
{
   public String resolve(final String name)
   {
       return name;
   }
   public void writeTo(final String fullyQualifedName, final Object 
model, final OutputStream out) throws IOException
   {
       final DataOutputStream dataOutputStream = new DataOutputStream(out);
       dataOutputStream.writeBytes("<html><body>"+fullyQualifedName + " 
<br></body></html>");
   }
}
---
Accessing http://localhost:8080/bookstore/anystring from webkit browser 
will return "<html><body>anystring <br></body></html>" with content type 
text/xml.
James Strachan wrote:
> 2009/2/5 Paul Sandoz <Paul.Sandoz_at_sun.com>:
>   
>> On Feb 4, 2009, at 6:45 PM, James Strachan wrote:
>>     
>>> Its much less essential, but supporting the nicer new MIME strings on
>>> @Produces would be great too - so you can use a single constant in
>>> your code to refer to a set of MIME types (e.g. application/xml,
>>> text/xml and application/json for example) to avoid having to cut and
>>> paste a String[] expression in each method using the @Produces
>>> annotation.
>>>
>>> I've raised an issue for this so we don't forget - but its more a case
>>> of making things more consistent and DRY, so way less important than
>>> support in @ImplicitProduces :)
>>> https://jersey.dev.java.net/issues/show_bug.cgi?id=202
>>>
>>>       
>> Thanks, for now i am not implementing proposed JAX-RS 1.1 features because
>> they have yet to be approved. Once approved i will start implementing such
>> features in earnest!
>>     
>
> Cool no worries! Just wanted to pop a test case in the issue tracker
> before I forgot.
>
>