You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2009/03/17 12:09:00 UTC

t5: intercepting exceptions from RequestExceptionHandler

Hi,

I have url like this:

http://localhost/display/ZmM%3D

but seems it will reject the parameter that has an equal sign even it is
urlencoded:

[ERROR] RequestExceptionHandler Processing of request failed with uncaught
exception: Input string 'ZmM=' is not valid; the character '=' at position 4
is not valid.

questions:

1) is there a way to let t5 accept the equal sign as part of url parameter?
2) how to intercept this exception in code?

Thanks,
-- 
View this message in context: http://www.nabble.com/t5%3A-intercepting-exceptions-from-RequestExceptionHandler-tp22556866p22556866.html
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: t5: intercepting exceptions from RequestExceptionHandler

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi Thiago,

You are right, the easiest way is to override that URLEncoder service, need
only add this:

markSafe("01234567890-_.:=");

Thiago H. de Paula Figueiredo wrote:
> 
> On Tue, Mar 17, 2009 at 9:40 AM, Angelo Chen <an...@yahoo.com.hk>
> wrote:
> 
>> Hi Thiago,
> 
> Hi!
> 
>> My problem is, those links are already distributed, can't be changed, if
>> I
>> can intercept this exception then I can redirect the process, any idea
>> how I
>> can intercept that exception?
> 
> One solution is to override the
> org.apache.tapestry5.services.URLEncoder service.
> To intercept exceptions, you'll need to override the
> RequestExceptionHandler service.
> 
> -- 
> Thiago
> 
> ---------------------------------------------------------------------
> 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/t5%3A-intercepting-exceptions-from-RequestExceptionHandler-tp22556866p22561105.html
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: t5: intercepting exceptions from RequestExceptionHandler

Posted by Angelo Chen <an...@yahoo.com.hk>.
In the upload request issue, I put:

  public static void
contributeHttpServletRequestHandler(OrderedConfiguration<HttpServletRequestFilter>
            configuration, MultipartDecoder multipartDecoder)
    {
        configuration.add("UploadRequestFilter", new UploadRequestFilter(),
"before:MultipartFilter");
    } 
but in this case, where should i put? of course not
"before:multipartFilter".


Thiago H. de Paula Figueiredo wrote:
> 
> On Tue, Mar 17, 2009 at 10:49 AM, Angelo Chen
> <an...@yahoo.com.hk> wrote:
> 
>> Hi Thiago,
>> I have code before, that was used to intercept file upload exceptions,
>> can
>> we use similar approach to intercept this exception too?
> 
> I guess so.
> 
> -- 
> Thiago
> 
> ---------------------------------------------------------------------
> 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/t5%3A-intercepting-exceptions-from-RequestExceptionHandler-tp22556866p22559859.html
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: t5: intercepting exceptions from RequestExceptionHandler

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, Mar 17, 2009 at 10:49 AM, Angelo Chen
<an...@yahoo.com.hk> wrote:

> Hi Thiago,
> I have code before, that was used to intercept file upload exceptions, can
> we use similar approach to intercept this exception too?

I guess so.

-- 
Thiago

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


Re: t5: intercepting exceptions from RequestExceptionHandler

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi Thiago,

I have code before, that was used to intercept file upload exceptions, can
we use similar approach to intercept this exception too?

public class UploadRequestFilter implements HttpServletRequestFilter {
    final private Logger logger;

    public UploadRequestFilter(Logger logger) {
        this.logger = logger;
    }

    public boolean service(HttpServletRequest request, HttpServletResponse
response,
                           HttpServletRequestHandler handler) throws
IOException {

        boolean result = true;
        try {
            result = handler.service(request, response);
        } catch (RuntimeException e) {
            Throwable err = e.getCause();
            logger.info(err.getMessage());
            if (err instanceof
FileUploadBase.FileSizeLimitExceededException) {
                    response.sendRedirect("/info/filesizeproblem");
            } else if (err instanceof FileUploadBase.IOFileUploadException)
{
                logger.error("looks like time out error");
                try {
                    throw err;
                } catch (Throwable throwable) {
                    throwable.printStackTrace();
                }
            } else {
            }
        }
        return result;
    }
}



Thiago H. de Paula Figueiredo wrote:
> 
> On Tue, Mar 17, 2009 at 9:40 AM, Angelo Chen <an...@yahoo.com.hk>
> wrote:
> 
>> Hi Thiago,
> 
> Hi!
> 
>> My problem is, those links are already distributed, can't be changed, if
>> I
>> can intercept this exception then I can redirect the process, any idea
>> how I
>> can intercept that exception?
> 
> One solution is to override the
> org.apache.tapestry5.services.URLEncoder service.
> To intercept exceptions, you'll need to override the
> RequestExceptionHandler service.
> 
> -- 
> Thiago
> 
> ---------------------------------------------------------------------
> 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/t5%3A-intercepting-exceptions-from-RequestExceptionHandler-tp22556866p22559028.html
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: t5: intercepting exceptions from RequestExceptionHandler

Posted by Robert Zeigler <ro...@scazdl.org>.
As an alternative to overriding, decorating RequestExceptionhandler  
might allow you to do what you want.

Robert

On Mar 17, 2009, at 3/177:47 AM , Thiago H. de Paula Figueiredo wrote:

> On Tue, Mar 17, 2009 at 9:40 AM, Angelo Chen <angelochen960@yahoo.com.hk 
> > wrote:
>
>> Hi Thiago,
>
> Hi!
>
>> My problem is, those links are already distributed, can't be  
>> changed, if I
>> can intercept this exception then I can redirect the process, any  
>> idea how I
>> can intercept that exception?
>
> One solution is to override the
> org.apache.tapestry5.services.URLEncoder service.
> To intercept exceptions, you'll need to override the
> RequestExceptionHandler service.
>
> -- 
> Thiago
>
> ---------------------------------------------------------------------
> 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: t5: intercepting exceptions from RequestExceptionHandler

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, Mar 17, 2009 at 9:40 AM, Angelo Chen <an...@yahoo.com.hk> wrote:

> Hi Thiago,

Hi!

> My problem is, those links are already distributed, can't be changed, if I
> can intercept this exception then I can redirect the process, any idea how I
> can intercept that exception?

One solution is to override the
org.apache.tapestry5.services.URLEncoder service.
To intercept exceptions, you'll need to override the
RequestExceptionHandler service.

-- 
Thiago

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


Re: t5: intercepting exceptions from RequestExceptionHandler

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi Thiago,

My problem is, those links are already distributed, can't be changed, if I
can intercept this exception then I can redirect the process, any idea how I
can intercept that exception?

Thanks,

Angelo


Thiago H. de Paula Figueiredo wrote:
> 
> I guess many people are having problems with the new URL decoding used
> by Tapestry since 5.0.16 (or some version near this one) as it does
> not accepts some valid URL encoded values. Angelo, while this is not
> solved in Tapestry itself, you can try changing your URL to
> /display?ZmM%3D and get the value through
> HttpServletRequest.getQueryString().
> 
> On Tue, Mar 17, 2009 at 8:09 AM, Angelo Chen <an...@yahoo.com.hk>
> wrote:
>>
>> Hi,
>>
>> I have url like this:
>>
>> http://localhost/display/ZmM%3D
>>
>> but seems it will reject the parameter that has an equal sign even it is
>> urlencoded:
>>
>> [ERROR] RequestExceptionHandler Processing of request failed with
>> uncaught
>> exception: Input string 'ZmM=' is not valid; the character '=' at
>> position 4
>> is not valid.
>>
>> questions:
>>
>> 1) is there a way to let t5 accept the equal sign as part of url
>> parameter?
>> 2) how to intercept this exception in code?
>>
>> Thanks,
>> --
>> View this message in context:
>> http://www.nabble.com/t5%3A-intercepting-exceptions-from-RequestExceptionHandler-tp22556866p22556866.html
>> 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
>>
>>
> 
> 
> 
> -- 
> Thiago
> 
> ---------------------------------------------------------------------
> 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/t5%3A-intercepting-exceptions-from-RequestExceptionHandler-tp22556866p22558331.html
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: t5: intercepting exceptions from RequestExceptionHandler

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
I guess many people are having problems with the new URL decoding used
by Tapestry since 5.0.16 (or some version near this one) as it does
not accepts some valid URL encoded values. Angelo, while this is not
solved in Tapestry itself, you can try changing your URL to
/display?ZmM%3D and get the value through
HttpServletRequest.getQueryString().

On Tue, Mar 17, 2009 at 8:09 AM, Angelo Chen <an...@yahoo.com.hk> wrote:
>
> Hi,
>
> I have url like this:
>
> http://localhost/display/ZmM%3D
>
> but seems it will reject the parameter that has an equal sign even it is
> urlencoded:
>
> [ERROR] RequestExceptionHandler Processing of request failed with uncaught
> exception: Input string 'ZmM=' is not valid; the character '=' at position 4
> is not valid.
>
> questions:
>
> 1) is there a way to let t5 accept the equal sign as part of url parameter?
> 2) how to intercept this exception in code?
>
> Thanks,
> --
> View this message in context: http://www.nabble.com/t5%3A-intercepting-exceptions-from-RequestExceptionHandler-tp22556866p22556866.html
> 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
>
>



-- 
Thiago

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