You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Davide Vecchi <dv...@amc.dk> on 2016/05/20 11:57:41 UTC

Encoding a space in querystring param using standard percent encoding

Hi everybody ,

In order to have a Tapestry page correctly receive an @ActivationRequestParameter , the value in the querystring must be sent encoded in the Tapestry way (f.ex. using Tapestry's URLEncoder service), so f.ex. a space char becomes $0020 , a "&"becomes $0026 etc.

However this encoding is Tapestry-specific while I need to write a page that can be called by third parties, which encode querystring parameters in the standard way, that is with "percent encoding", where f.ex. a space becomes %20 instead of $0020.

Currently when my Tapestry page receives a querystring parameter containing a character encoded in that way, f.ex.

	TestPage?myParam=A%20Z

, I get a ComponentEventException:

	Input string 'A Z' is not valid; the character ' ' at position 2 is not valid.

From that error message it would appear that Tapestry does correctly decode the %20 into a space, but at the same time it throws the exception, while if I use Tapestry encoding for that char, so

	TestPage?myParam=A$0020Z

, everything is good and no exception is thrown.

So I would like to know if there is a clean / recommended approach to receiving percent-encoded parameters like %20 from a Tapestry page.

Although I'm currently using @ActivationRequestParameter, this is not a requirement so it would not be a problem to drop this annotation and use something else if necessary.

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


RE: Encoding a space in querystring param using standard percent encoding

Posted by Davide Vecchi <dv...@amc.dk>.
Felix, that's brilliant, thanks a lot, it solved my problem. I had no idea that request.getParameter and @ActivationRequestParameter use different encoding schemes.

Thanks

-----Original Message-----
From: Felix Gonschorek [mailto:felix@netzgut.net] 
Sent: Friday, May 20, 2016 14:11
To: Tapestry users <us...@tapestry.apache.org>
Subject: Re: Encoding a space in querystring param using standard percent encoding

Hello Davide,

you can inject the Request (org.apache.tapestry5.services.Request) service into your page and then access the parameter with

request.getParameter("myParam")

this should go around the tapestry encoding and type coercing mechanisms.

Felix


Re: Encoding a space in querystring param using standard percent encoding

Posted by Felix Gonschorek <fe...@netzgut.net>.
Hello Davide,

you can inject the Request (org.apache.tapestry5.services.Request) service
into your page and then access the parameter with

request.getParameter("myParam")

this should go around the tapestry encoding and type coercing mechanisms.

Felix

2016-05-20 13:57 GMT+02:00 Davide Vecchi <dv...@amc.dk>:

> Hi everybody ,
>
> In order to have a Tapestry page correctly receive an
> @ActivationRequestParameter , the value in the querystring must be sent
> encoded in the Tapestry way (f.ex. using Tapestry's URLEncoder service), so
> f.ex. a space char becomes $0020 , a "&"becomes $0026 etc.
>
> However this encoding is Tapestry-specific while I need to write a page
> that can be called by third parties, which encode querystring parameters in
> the standard way, that is with "percent encoding", where f.ex. a space
> becomes %20 instead of $0020.
>
> Currently when my Tapestry page receives a querystring parameter
> containing a character encoded in that way, f.ex.
>
>         TestPage?myParam=A%20Z
>
> , I get a ComponentEventException:
>
>         Input string 'A Z' is not valid; the character ' ' at position 2
> is not valid.
>
> From that error message it would appear that Tapestry does correctly
> decode the %20 into a space, but at the same time it throws the exception,
> while if I use Tapestry encoding for that char, so
>
>         TestPage?myParam=A$0020Z
>
> , everything is good and no exception is thrown.
>
> So I would like to know if there is a clean / recommended approach to
> receiving percent-encoded parameters like %20 from a Tapestry page.
>
> Although I'm currently using @ActivationRequestParameter, this is not a
> requirement so it would not be a problem to drop this annotation and use
> something else if necessary.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>