Using web.xml to automatically redirect to error page on any error

1,438 views
Skip to first unread message

Yaakov

unread,
Nov 25, 2010, 12:30:46 AM11/25/10
to Google Web Toolkit
Hi,

I thought I have done this before with GWT...

I have an RPC call to some resource. If something unforeseen (untested
bug) happens during the RPC call in the server-side processing, I want
to use the regular error-page mechanism to automatically redirect the
browser to some standard error page (where it would announce that we
are finding whoever introduced that bug and firing them :-) )

I set this up in web.xml like this:
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/WEB-INF/pages/error.jsp</location>
</error-page>

For testing, I try throwing NullPointerException from within my server-
side code. The exception seems to slip through the 'error-page'
mechanism and still shows up in GWT, i.e., in the browser with this:
"com.google.gwt.user.client.rpc.StatusCodeException: The call failed
on the server; see server log for details"

Is what I am trying to do not possible in GWT??? Frankly, and maybe
because it's late :-), I don't understand why the 'error-page'
mechanism doesn't kick in no matter what and return the contents of
the error.jsp page at least. I.e., GWT should have no idea that an
error even occurred because the 'error-page' mechanism should have
caught it before the response goes back to the client.

Any ideas anyone?

Thanks,
Yaakov.

ep

unread,
Nov 25, 2010, 3:47:44 AM11/25/10
to Google Web Toolkit
hi, u think the right way :-)

how did you define your RemoteService methods? have you defined them
to throw exceptions?
GWT RPC works the way that it tries to forward (serialize) caught
exception to the client, if it is able to. that means, that if you
throw a NPE from your service implementation, you dont get 500 code
from the server, rather it would be http 200 (ok) and the exception is
serialized and streamed to the client, where RPC stack detects that
this is an exception and propagates to the onFailure() callback of the
Async implementation.

So the servlet container never guess there went something wrong.

On the other hand - I would not advise to break it, you dont need your
custom error handling for RPC, since you never call them manually
(i.e. by link) but rather over RPC, so a common error.jsp showing up
some warning information to the user would never do its job here,
since a user would never see that page.

Yaakov Chaikin

unread,
Nov 25, 2010, 8:15:17 AM11/25/10
to google-we...@googlegroups.com
Hmm... Makes sense... For some reason, I thought I've gotten the
browser to display the entire error page somehow, not the error page
as part of the Ajax response. But you are right, it does make sense
that even if the 'error-page' mechanism succeeds, it would make sense
that the error page content should just be returned as a "success"
response to the Ajax call and that's certainly NOT what I want.

Thanks.

-Yaakov.

> --
> You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
> To post to this group, send email to google-we...@googlegroups.com.
> To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages