You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by thanos <at...@gmail.com> on 2007/11/13 19:58:31 UTC

TextStreamResponse and XML and UTF-8

Hi all,

I am trying to return an rss feed using TextStreamResponse("text/xml",
myfeed);

The problem is the that I can't make TextStreamResponse to show UTF-8 (greek
in my case) characters.
I tried to set the content type in the response of RequestGlobals and also
added a Utf8Filter with no luck

The same feed is displayed fine when I requested through a simple servlet. 
I can see the characters in the returned string, and if I save the page
source as an UTF-8 file I can displayed it correctly.

However, I can't make my browser or my GUI to display the xml if I directly
request it using TextStreamResponse.

Dont know if it's related with this post:

http://www.nabble.com/T5-confused-about-Services-and-XmlHttpResponse-tf4160459.html#a11839004

Any advice plz?

Thanks
Thanos

-- 
View this message in context: http://www.nabble.com/TextStreamResponse-and-XML-and-UTF-8-tf4799847.html#a13732229
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


ExtJs and Tapestry

Posted by su...@gmx.de.
Are there an ExtJS components for Tapestry yet?

http://extjs.com/what-ext-javascript-library-all-about

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: TextStreamResponse and XML and UTF-8

Posted by 陆惠国 <lu...@gmail.com>.
FIX  TextStreamResponse

 public InputStream getStream() throws IOException {
        ContentType ct = new ContentType(_contentType);
        String charset = ct.getParameter("charset");
        if (StringUtils.isNotBlank(charset)) {
            return new ByteArrayInputStream(_text.getBytes(charset));
        } else {
            return new ByteArrayInputStream(_text.getBytes());
        }

    }

USE:
return new TextStreamResponse("text/html;charset=UTF-8", writer.toString());


2007/11/14, thanos <at...@gmail.com>:
>
>
> Yes, forcing the encoding to "UTF-8" inside a ByteArrayInputStream did the
> trick.
> It works now!
>
> I will soon make some tests to compare the two approaches (Template based
> XML vs StreamResponse), since perfomance was the main reason I switched to
> Tapestry. Will keep you posted.
>
> Many thanks to all of you guys :)
>
>
> Nick Westgate wrote:
> >
> >  > The problem is the that I can't make TextStreamResponse to show UTF-8
> > (greek
> >  > in my case) characters.
> >  > Dont know if it's related with this post:
> >  >
> >  >
> >
> http://www.nabble.com/T5-confused-about-Services-and-XmlHttpResponse-tf4160459.html#a11839004
> >
> > Yes, my previous post pointed out a solution. Here's some source ...
> >
> > Cheers,
> > Nick.
> >
> >
> > // Copyright 2007 The Apache Software Foundation
> > //
> > // Licensed under the Apache License, Version 2.0 (the "License");
> > // you may not use this file except in compliance with the License.
> > // You may obtain a copy of the License at
> > //
> > // http://www.apache.org/licenses/LICENSE-2.0
> > //
> > // Unless required by applicable law or agreed to in writing, software
> > // distributed under the License is distributed on an "AS IS" BASIS,
> > // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > implied.
> > // See the License for the specific language governing permissions and
> > // limitations under the License.
> >
> > package yourapp.tapestry.utility;
> >
> > import static org.apache.tapestry.ioc.internal.util.Defense.notBlank;
> > import static org.apache.tapestry.ioc.internal.util.Defense.notNull;
> >
> > import java.io.ByteArrayInputStream;
> > import java.io.IOException;
> > import java.io.InputStream;
> >
> > import org.apache.tapestry.StreamResponse;
> > import org.apache.tapestry.services.Response;
> >
> > public class TextStreamResponseFix implements StreamResponse
> > {
> >      private final String _contentType;
> >
> >      private final String _text;
> >
> >      private String _encoding;
> >
> >      public TextStreamResponseFix(final String contentType, final String
> > text)
> >      {
> >          notBlank(contentType, "contentType");
> >          notNull(text, "text");
> >
> >          _contentType = contentType;
> >          _text = text;
> >      }
> >
> >      public TextStreamResponseFix(
> >          final String contentType,
> >          final String text,
> >          final String encoding)
> >      {
> >          this(contentType, text);
> >
> >          _encoding = encoding;
> >      }
> >
> >      public String getContentType()
> >      {
> >          return _contentType;
> >      }
> >
> >      public InputStream getStream() throws IOException
> >      {
> >          return new ByteArrayInputStream((_encoding == null) ?
> > _text.getBytes()
> >              : _text.getBytes(_encoding));
> >      }
> >
> >      public void prepareResponse(Response response)
> >      {
> >          // No-op by default.
> >      }
> > }
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/TextStreamResponse-and-XML-and-UTF-8-tf4799847.html#a13746317
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: TextStreamResponse and XML and UTF-8

Posted by thanos <at...@gmail.com>.
Yes, forcing the encoding to "UTF-8" inside a ByteArrayInputStream did the
trick. 
It works now!

I will soon make some tests to compare the two approaches (Template based
XML vs StreamResponse), since perfomance was the main reason I switched to
Tapestry. Will keep you posted.

Many thanks to all of you guys :)


Nick Westgate wrote:
> 
>  > The problem is the that I can't make TextStreamResponse to show UTF-8
> (greek
>  > in my case) characters.
>  > Dont know if it's related with this post:
>  >
>  >
> http://www.nabble.com/T5-confused-about-Services-and-XmlHttpResponse-tf4160459.html#a11839004
> 
> Yes, my previous post pointed out a solution. Here's some source ...
> 
> Cheers,
> Nick.
> 
> 
> // Copyright 2007 The Apache Software Foundation
> //
> // Licensed under the Apache License, Version 2.0 (the "License");
> // you may not use this file except in compliance with the License.
> // You may obtain a copy of the License at
> //
> // http://www.apache.org/licenses/LICENSE-2.0
> //
> // Unless required by applicable law or agreed to in writing, software
> // distributed under the License is distributed on an "AS IS" BASIS,
> // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> // See the License for the specific language governing permissions and
> // limitations under the License.
> 
> package yourapp.tapestry.utility;
> 
> import static org.apache.tapestry.ioc.internal.util.Defense.notBlank;
> import static org.apache.tapestry.ioc.internal.util.Defense.notNull;
> 
> import java.io.ByteArrayInputStream;
> import java.io.IOException;
> import java.io.InputStream;
> 
> import org.apache.tapestry.StreamResponse;
> import org.apache.tapestry.services.Response;
> 
> public class TextStreamResponseFix implements StreamResponse
> {
>      private final String _contentType;
> 
>      private final String _text;
> 
>      private String _encoding;
> 
>      public TextStreamResponseFix(final String contentType, final String
> text)
>      {
>          notBlank(contentType, "contentType");
>          notNull(text, "text");
> 
>          _contentType = contentType;
>          _text = text;
>      }
> 
>      public TextStreamResponseFix(
>          final String contentType,
>          final String text,
>          final String encoding)
>      {
>          this(contentType, text);
> 
>          _encoding = encoding;
>      }
> 
>      public String getContentType()
>      {
>          return _contentType;
>      }
> 
>      public InputStream getStream() throws IOException
>      {
>          return new ByteArrayInputStream((_encoding == null) ?
> _text.getBytes()
>              : _text.getBytes(_encoding));
>      }
> 
>      public void prepareResponse(Response response)
>      {
>          // No-op by default.
>      }
> }
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/TextStreamResponse-and-XML-and-UTF-8-tf4799847.html#a13746317
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: TextStreamResponse and XML and UTF-8

Posted by Nick Westgate <ni...@key-planning.co.jp>.
 > The problem is the that I can't make TextStreamResponse to show UTF-8 (greek
 > in my case) characters.
 > Dont know if it's related with this post:
 >
 > http://www.nabble.com/T5-confused-about-Services-and-XmlHttpResponse-tf4160459.html#a11839004

Yes, my previous post pointed out a solution. Here's some source ...

Cheers,
Nick.


// Copyright 2007 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package yourapp.tapestry.utility;

import static org.apache.tapestry.ioc.internal.util.Defense.notBlank;
import static org.apache.tapestry.ioc.internal.util.Defense.notNull;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

import org.apache.tapestry.StreamResponse;
import org.apache.tapestry.services.Response;

public class TextStreamResponseFix implements StreamResponse
{
     private final String _contentType;

     private final String _text;

     private String _encoding;

     public TextStreamResponseFix(final String contentType, final String text)
     {
         notBlank(contentType, "contentType");
         notNull(text, "text");

         _contentType = contentType;
         _text = text;
     }

     public TextStreamResponseFix(
         final String contentType,
         final String text,
         final String encoding)
     {
         this(contentType, text);

         _encoding = encoding;
     }

     public String getContentType()
     {
         return _contentType;
     }

     public InputStream getStream() throws IOException
     {
         return new ByteArrayInputStream((_encoding == null) ? _text.getBytes()
             : _text.getBytes(_encoding));
     }

     public void prepareResponse(Response response)
     {
         // No-op by default.
     }
}


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: TextStreamResponse and XML and UTF-8

Posted by Ezra Epstein <ez...@yahoo.com>.
This is another way to do it.  Look at the code for TextStreamResponse.  Write your own StreamResponse impl that's backed by a ByteArrayInputStream.

(The reason I avoid that approach is (a) you create an InputStream to write a response, so under the covers Tap5 is reading from it and writing to the actual HTTP output stream which means that (b) the performance is a bit degraded and (c) you have to hold the whole reply in memory rather than streaming it back to the client.)

Fernando Padilla <fe...@alum.mit.edu> wrote: Essentially, you gave it a string (UTF16 in memory), and it is being
converted into bytes ( string.getBytes() within TextStreamResponse ).
And the contentType of the response is set also from TextStreamResponse.

I would double check what the string.getBytes() is returning, maybe it's
actually putting out bytes in UTF-8, but the HTTP response assumes it's
not in UTF-8, but ISO-LATIN-1 or somesuch.  So you're getting the
correct bytes, but they are being interpreted wrong..

1) you might just have to add the charset to the mimetype..
"text/xml;charset=UTF-8"?

2) If you want your 3rd party library to take over more rendering, then
create StreamResponse object that goes from a byte[] instead of a
String, then you have full control on how that strings gets encoded
(utf-8 charset).

3) Maybe there is a bug/enhancement here and
StreamResponseResultProcessor, and TextStreamResponse should be paying
more attention to the charset of the mimetype.





thanos wrote:
> I used 
>     boolean beforeRenderTemplate(){
>      return false;
>     }
> but couldn't skip rendering check
> 
> I will currently return xml using a template with the help of Fernando's
> patch - TAPESTRY-1600.
> This patch allows the generation of xml, from an xml-based description by
> fixing the "cutting" of namespaces from tapestry. This way I a can set and
> keep UTF-8 encoding.
> 
> I would like, however, to have the option to return a complete UTF-8 xml/rss
> created from say another library (I am currently using rome), using
> TextStreamResponse or Printwriter, so if anyone has a code example that will
> actually perform my original request, please post it here.
> 
> 
> 
> 
> 
> Vashon-Ez wrote:
>> You can override one of the page render methods (I think onactivate is one
>> of those, but check the Tap5 website) and return false !!!! to tell Tap to
>> skip the other steps of page rendering.
>>
>> thanos  wrote: 
>> thank you.
>>
>> I tried that but I get a mix of xml and html erro String (insteαd of
>> clean
>> xml document) as a response. Seems that it looks for a template (I dont
>> have
>> one cause I didnt need it with textStreamResponse)
>>
>> Inside onActivate I obtain a PrintWriter from the injected Response, using
>> "application/xml; charset=UTF-8"
>> as content type. I print a small test xml string in printwriter and then I
>> flush the printwriter.
>>
>> I return null in onActivate().
>>
>> Did I do something wrong? 
>>
>>
>>
>>
>>
>> Vashon-Ez wrote:
>>> If you're just returning an RSS feed you probably don't want any page
>>> wrapping, etc.  In that case you can:
>>>
>>> @Inject
>>> private Response _response;
>>>
>>> You can then do things like setting headers and even write directly to
>>> the
>>> container-provided OutputStream - bypassing the whole TextStreamResponse
>>> -- just have your method flsuh() the output stream and return null.  This
>>> should also give slightly better performance.
>>>
>>> HTH,
>>>
>>> EE
>>>
>>> thanos  wrote: 
>>> Hi all,
>>>
>>> I am trying to return an rss feed using TextStreamResponse("text/xml",
>>> myfeed);
>>>
>>> The problem is the that I can't make TextStreamResponse to show UTF-8
>>> (greek
>>> in my case) characters.
>>> I tried to set the content type in the response of RequestGlobals and
>>> also
>>> added a Utf8Filter with no luck
>>>
>>> The same feed is displayed fine when I requested through a simple
>>> servlet. 
>>> I can see the characters in the returned string, and if I save the page
>>> source as an UTF-8 file I can displayed it correctly.
>>>
>>> However, I can't make my browser or my GUI to display the xml if I
>>> directly
>>> request it using TextStreamResponse.
>>>
>>> Dont know if it's related with this post:
>>>
>>> http://www.nabble.com/T5-confused-about-Services-and-XmlHttpResponse-tf4160459.html#a11839004
>>>
>>> Any advice plz?
>>>
>>> Thanks
>>> Thanos
>>>
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/TextStreamResponse-and-XML-and-UTF-8-tf4799847.html#a13732229
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/TextStreamResponse-and-XML-and-UTF-8-tf4799847.html#a13736449
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>
>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org



Re: TextStreamResponse and XML and UTF-8

Posted by Fernando Padilla <fe...@alum.mit.edu>.
Essentially, you gave it a string (UTF16 in memory), and it is being
converted into bytes ( string.getBytes() within TextStreamResponse ).
And the contentType of the response is set also from TextStreamResponse.

I would double check what the string.getBytes() is returning, maybe it's
actually putting out bytes in UTF-8, but the HTTP response assumes it's
not in UTF-8, but ISO-LATIN-1 or somesuch.  So you're getting the
correct bytes, but they are being interpreted wrong..

1) you might just have to add the charset to the mimetype..
"text/xml;charset=UTF-8"?

2) If you want your 3rd party library to take over more rendering, then
create StreamResponse object that goes from a byte[] instead of a
String, then you have full control on how that strings gets encoded
(utf-8 charset).

3) Maybe there is a bug/enhancement here and
StreamResponseResultProcessor, and TextStreamResponse should be paying
more attention to the charset of the mimetype.





thanos wrote:
> I used 
>     boolean beforeRenderTemplate(){
>      return false;
>     }
> but couldn't skip rendering check
> 
> I will currently return xml using a template with the help of Fernando's
> patch - TAPESTRY-1600.
> This patch allows the generation of xml, from an xml-based description by
> fixing the "cutting" of namespaces from tapestry. This way I a can set and
> keep UTF-8 encoding.
> 
> I would like, however, to have the option to return a complete UTF-8 xml/rss
> created from say another library (I am currently using rome), using
> TextStreamResponse or Printwriter, so if anyone has a code example that will
> actually perform my original request, please post it here.
> 
> 
> 
> 
> 
> Vashon-Ez wrote:
>> You can override one of the page render methods (I think onactivate is one
>> of those, but check the Tap5 website) and return false !!!! to tell Tap to
>> skip the other steps of page rendering.
>>
>> thanos <at...@gmail.com> wrote: 
>> thank you.
>>
>> I tried that but I get a mix of xml and html erro String (insteαd of
>> clean
>> xml document) as a response. Seems that it looks for a template (I dont
>> have
>> one cause I didnt need it with textStreamResponse)
>>
>> Inside onActivate I obtain a PrintWriter from the injected Response, using
>> "application/xml; charset=UTF-8"
>> as content type. I print a small test xml string in printwriter and then I
>> flush the printwriter.
>>
>> I return null in onActivate().
>>
>> Did I do something wrong? 
>>
>>
>>
>>
>>
>> Vashon-Ez wrote:
>>> If you're just returning an RSS feed you probably don't want any page
>>> wrapping, etc.  In that case you can:
>>>
>>> @Inject
>>> private Response _response;
>>>
>>> You can then do things like setting headers and even write directly to
>>> the
>>> container-provided OutputStream - bypassing the whole TextStreamResponse
>>> -- just have your method flsuh() the output stream and return null.  This
>>> should also give slightly better performance.
>>>
>>> HTH,
>>>
>>> EE
>>>
>>> thanos  wrote: 
>>> Hi all,
>>>
>>> I am trying to return an rss feed using TextStreamResponse("text/xml",
>>> myfeed);
>>>
>>> The problem is the that I can't make TextStreamResponse to show UTF-8
>>> (greek
>>> in my case) characters.
>>> I tried to set the content type in the response of RequestGlobals and
>>> also
>>> added a Utf8Filter with no luck
>>>
>>> The same feed is displayed fine when I requested through a simple
>>> servlet. 
>>> I can see the characters in the returned string, and if I save the page
>>> source as an UTF-8 file I can displayed it correctly.
>>>
>>> However, I can't make my browser or my GUI to display the xml if I
>>> directly
>>> request it using TextStreamResponse.
>>>
>>> Dont know if it's related with this post:
>>>
>>> http://www.nabble.com/T5-confused-about-Services-and-XmlHttpResponse-tf4160459.html#a11839004
>>>
>>> Any advice plz?
>>>
>>> Thanks
>>> Thanos
>>>
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/TextStreamResponse-and-XML-and-UTF-8-tf4799847.html#a13732229
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/TextStreamResponse-and-XML-and-UTF-8-tf4799847.html#a13736449
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>
>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: TextStreamResponse and XML and UTF-8

Posted by thanos <at...@gmail.com>.
I used 
    boolean beforeRenderTemplate(){
     return false;
    }
but couldn't skip rendering check

I will currently return xml using a template with the help of Fernando's
patch - TAPESTRY-1600.
This patch allows the generation of xml, from an xml-based description by
fixing the "cutting" of namespaces from tapestry. This way I a can set and
keep UTF-8 encoding.

I would like, however, to have the option to return a complete UTF-8 xml/rss
created from say another library (I am currently using rome), using
TextStreamResponse or Printwriter, so if anyone has a code example that will
actually perform my original request, please post it here.





Vashon-Ez wrote:
> 
> You can override one of the page render methods (I think onactivate is one
> of those, but check the Tap5 website) and return false !!!! to tell Tap to
> skip the other steps of page rendering.
> 
> thanos <at...@gmail.com> wrote: 
> thank you.
> 
> I tried that but I get a mix of xml and html erro String (insteαd of
> clean
> xml document) as a response. Seems that it looks for a template (I dont
> have
> one cause I didnt need it with textStreamResponse)
> 
> Inside onActivate I obtain a PrintWriter from the injected Response, using
> "application/xml; charset=UTF-8"
> as content type. I print a small test xml string in printwriter and then I
> flush the printwriter.
> 
> I return null in onActivate().
> 
> Did I do something wrong? 
> 
> 
> 
> 
> 
> Vashon-Ez wrote:
>> 
>> If you're just returning an RSS feed you probably don't want any page
>> wrapping, etc.  In that case you can:
>> 
>> @Inject
>> private Response _response;
>> 
>> You can then do things like setting headers and even write directly to
>> the
>> container-provided OutputStream - bypassing the whole TextStreamResponse
>> -- just have your method flsuh() the output stream and return null.  This
>> should also give slightly better performance.
>> 
>> HTH,
>> 
>> EE
>> 
>> thanos  wrote: 
>> Hi all,
>> 
>> I am trying to return an rss feed using TextStreamResponse("text/xml",
>> myfeed);
>> 
>> The problem is the that I can't make TextStreamResponse to show UTF-8
>> (greek
>> in my case) characters.
>> I tried to set the content type in the response of RequestGlobals and
>> also
>> added a Utf8Filter with no luck
>> 
>> The same feed is displayed fine when I requested through a simple
>> servlet. 
>> I can see the characters in the returned string, and if I save the page
>> source as an UTF-8 file I can displayed it correctly.
>> 
>> However, I can't make my browser or my GUI to display the xml if I
>> directly
>> request it using TextStreamResponse.
>> 
>> Dont know if it's related with this post:
>> 
>> http://www.nabble.com/T5-confused-about-Services-and-XmlHttpResponse-tf4160459.html#a11839004
>> 
>> Any advice plz?
>> 
>> Thanks
>> Thanos
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/TextStreamResponse-and-XML-and-UTF-8-tf4799847.html#a13732229
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>> 
>> 
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/TextStreamResponse-and-XML-and-UTF-8-tf4799847.html#a13736449
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/TextStreamResponse-and-XML-and-UTF-8-tf4799847.html#a13738520
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: TextStreamResponse and XML and UTF-8

Posted by Ezra Epstein <ez...@yahoo.com>.
You can override one of the page render methods (I think onactivate is one of those, but check the Tap5 website) and return false !!!! to tell Tap to skip the other steps of page rendering.

thanos <at...@gmail.com> wrote: 
thank you.

I tried that but I get a mix of xml and html erro String (insteαd of clean
xml document) as a response. Seems that it looks for a template (I dont have
one cause I didnt need it with textStreamResponse)

Inside onActivate I obtain a PrintWriter from the injected Response, using
"application/xml; charset=UTF-8"
as content type. I print a small test xml string in printwriter and then I
flush the printwriter.

I return null in onActivate().

Did I do something wrong? 





Vashon-Ez wrote:
> 
> If you're just returning an RSS feed you probably don't want any page
> wrapping, etc.  In that case you can:
> 
> @Inject
> private Response _response;
> 
> You can then do things like setting headers and even write directly to the
> container-provided OutputStream - bypassing the whole TextStreamResponse
> -- just have your method flsuh() the output stream and return null.  This
> should also give slightly better performance.
> 
> HTH,
> 
> EE
> 
> thanos  wrote: 
> Hi all,
> 
> I am trying to return an rss feed using TextStreamResponse("text/xml",
> myfeed);
> 
> The problem is the that I can't make TextStreamResponse to show UTF-8
> (greek
> in my case) characters.
> I tried to set the content type in the response of RequestGlobals and also
> added a Utf8Filter with no luck
> 
> The same feed is displayed fine when I requested through a simple servlet. 
> I can see the characters in the returned string, and if I save the page
> source as an UTF-8 file I can displayed it correctly.
> 
> However, I can't make my browser or my GUI to display the xml if I
> directly
> request it using TextStreamResponse.
> 
> Dont know if it's related with this post:
> 
> http://www.nabble.com/T5-confused-about-Services-and-XmlHttpResponse-tf4160459.html#a11839004
> 
> Any advice plz?
> 
> Thanks
> Thanos
> 
> -- 
> View this message in context:
> http://www.nabble.com/TextStreamResponse-and-XML-and-UTF-8-tf4799847.html#a13732229
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/TextStreamResponse-and-XML-and-UTF-8-tf4799847.html#a13736449
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org



Re: TextStreamResponse and XML and UTF-8

Posted by thanos <at...@gmail.com>.
thank you.

I tried that but I get a mix of xml and html erro String (insteαd of clean
xml document) as a response. Seems that it looks for a template (I dont have
one cause I didnt need it with textStreamResponse)

Inside onActivate I obtain a PrintWriter from the injected Response, using
"application/xml; charset=UTF-8"
as content type. I print a small test xml string in printwriter and then I
flush the printwriter.

I return null in onActivate().

Did I do something wrong? 





Vashon-Ez wrote:
> 
> If you're just returning an RSS feed you probably don't want any page
> wrapping, etc.  In that case you can:
> 
> @Inject
> private Response _response;
> 
> You can then do things like setting headers and even write directly to the
> container-provided OutputStream - bypassing the whole TextStreamResponse
> -- just have your method flsuh() the output stream and return null.  This
> should also give slightly better performance.
> 
> HTH,
> 
> EE
> 
> thanos <at...@gmail.com> wrote: 
> Hi all,
> 
> I am trying to return an rss feed using TextStreamResponse("text/xml",
> myfeed);
> 
> The problem is the that I can't make TextStreamResponse to show UTF-8
> (greek
> in my case) characters.
> I tried to set the content type in the response of RequestGlobals and also
> added a Utf8Filter with no luck
> 
> The same feed is displayed fine when I requested through a simple servlet. 
> I can see the characters in the returned string, and if I save the page
> source as an UTF-8 file I can displayed it correctly.
> 
> However, I can't make my browser or my GUI to display the xml if I
> directly
> request it using TextStreamResponse.
> 
> Dont know if it's related with this post:
> 
> http://www.nabble.com/T5-confused-about-Services-and-XmlHttpResponse-tf4160459.html#a11839004
> 
> Any advice plz?
> 
> Thanks
> Thanos
> 
> -- 
> View this message in context:
> http://www.nabble.com/TextStreamResponse-and-XML-and-UTF-8-tf4799847.html#a13732229
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/TextStreamResponse-and-XML-and-UTF-8-tf4799847.html#a13736449
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: TextStreamResponse and XML and UTF-8

Posted by Ezra Epstein <ez...@yahoo.com>.
If you're just returning an RSS feed you probably don't want any page wrapping, etc.  In that case you can:

@Inject
private Response _response;

You can then do things like setting headers and even write directly to the container-provided OutputStream - bypassing the whole TextStreamResponse -- just have your method flsuh() the output stream and return null.  This should also give slightly better performance.

HTH,

EE

thanos <at...@gmail.com> wrote: 
Hi all,

I am trying to return an rss feed using TextStreamResponse("text/xml",
myfeed);

The problem is the that I can't make TextStreamResponse to show UTF-8 (greek
in my case) characters.
I tried to set the content type in the response of RequestGlobals and also
added a Utf8Filter with no luck

The same feed is displayed fine when I requested through a simple servlet. 
I can see the characters in the returned string, and if I save the page
source as an UTF-8 file I can displayed it correctly.

However, I can't make my browser or my GUI to display the xml if I directly
request it using TextStreamResponse.

Dont know if it's related with this post:

http://www.nabble.com/T5-confused-about-Services-and-XmlHttpResponse-tf4160459.html#a11839004

Any advice plz?

Thanks
Thanos

-- 
View this message in context: http://www.nabble.com/TextStreamResponse-and-XML-and-UTF-8-tf4799847.html#a13732229
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org