You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Borut Bolčina <bo...@gmail.com> on 2009/04/23 15:12:48 UTC

Dispatcher returning XML

Hello,

I have a dispatcher which matches some URL pattern like this:

    public boolean dispatch(Request request, Response response) throws
IOException {
        String path = request.getPath();
        // just imagine this works ok
        String uglyWord =  request.getContextPath() == "" ?
StringUtils.substringAfterLast(path, "/") : path.substring(1);

        if (uglyWordSet.contains(uglyWord)) {
            // return some XML if url contains some ugly word
            // WHAT IS THE BEST APPROACH TO RETURN XML (STREAM) ?
            return true;
        }

        return false;
    }

I know how to create a page which returns xml stream response (I
actually have one). Can I just reuse this page?

Using T 5.0.18.

Regards,
Borut

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


Re: Dispatcher returning XML

Posted by Howard Lewis Ship <hl...@gmail.com>.
A dispatcher is even easier; just think of it as a servlet that
returns true if it "handles the request". Get a response stream and
write XML to it.

On Thu, Apr 23, 2009 at 3:05 PM, Borut Bolčina <bo...@gmail.com> wrote:
> Thanks, but I am not sure how to do that in a dispatcher.
>
> -Borut
>
> 2009/4/23 Howard Lewis Ship <hl...@gmail.com>:
>> You can return a StreamResponse whose job is to generate an
>> InputStream of XML to be sent to the client.
>>
>> On Thu, Apr 23, 2009 at 6:12 AM, Borut Bolčina <bo...@gmail.com> wrote:
>>> Hello,
>>>
>>> I have a dispatcher which matches some URL pattern like this:
>>>
>>>    public boolean dispatch(Request request, Response response) throws
>>> IOException {
>>>        String path = request.getPath();
>>>        // just imagine this works ok
>>>        String uglyWord =  request.getContextPath() == "" ?
>>> StringUtils.substringAfterLast(path, "/") : path.substring(1);
>>>
>>>        if (uglyWordSet.contains(uglyWord)) {
>>>            // return some XML if url contains some ugly word
>>>            // WHAT IS THE BEST APPROACH TO RETURN XML (STREAM) ?
>>>            return true;
>>>        }
>>>
>>>        return false;
>>>    }
>>>
>>> I know how to create a page which returns xml stream response (I
>>> actually have one). Can I just reuse this page?
>>>
>>> Using T 5.0.18.
>>>
>>> Regards,
>>> Borut
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>>
>>
>> --
>> Howard M. Lewis Ship
>>
>> Creator of Apache Tapestry
>> Director of Open Source Technology at Formos
>>
>> ---------------------------------------------------------------------
>> 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
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry
Director of Open Source Technology at Formos

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


Re: Dispatcher returning XML

Posted by Borut Bolčina <bo...@gmail.com>.
Thanks, but I am not sure how to do that in a dispatcher.

-Borut

2009/4/23 Howard Lewis Ship <hl...@gmail.com>:
> You can return a StreamResponse whose job is to generate an
> InputStream of XML to be sent to the client.
>
> On Thu, Apr 23, 2009 at 6:12 AM, Borut Bolčina <bo...@gmail.com> wrote:
>> Hello,
>>
>> I have a dispatcher which matches some URL pattern like this:
>>
>>    public boolean dispatch(Request request, Response response) throws
>> IOException {
>>        String path = request.getPath();
>>        // just imagine this works ok
>>        String uglyWord =  request.getContextPath() == "" ?
>> StringUtils.substringAfterLast(path, "/") : path.substring(1);
>>
>>        if (uglyWordSet.contains(uglyWord)) {
>>            // return some XML if url contains some ugly word
>>            // WHAT IS THE BEST APPROACH TO RETURN XML (STREAM) ?
>>            return true;
>>        }
>>
>>        return false;
>>    }
>>
>> I know how to create a page which returns xml stream response (I
>> actually have one). Can I just reuse this page?
>>
>> Using T 5.0.18.
>>
>> Regards,
>> Borut
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator of Apache Tapestry
> Director of Open Source Technology at Formos
>
> ---------------------------------------------------------------------
> 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: Dispatcher returning XML

Posted by Howard Lewis Ship <hl...@gmail.com>.
You can return a StreamResponse whose job is to generate an
InputStream of XML to be sent to the client.

On Thu, Apr 23, 2009 at 6:12 AM, Borut Bolčina <bo...@gmail.com> wrote:
> Hello,
>
> I have a dispatcher which matches some URL pattern like this:
>
>    public boolean dispatch(Request request, Response response) throws
> IOException {
>        String path = request.getPath();
>        // just imagine this works ok
>        String uglyWord =  request.getContextPath() == "" ?
> StringUtils.substringAfterLast(path, "/") : path.substring(1);
>
>        if (uglyWordSet.contains(uglyWord)) {
>            // return some XML if url contains some ugly word
>            // WHAT IS THE BEST APPROACH TO RETURN XML (STREAM) ?
>            return true;
>        }
>
>        return false;
>    }
>
> I know how to create a page which returns xml stream response (I
> actually have one). Can I just reuse this page?
>
> Using T 5.0.18.
>
> Regards,
> Borut
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry
Director of Open Source Technology at Formos

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