I'm new user of GWT. I'm trying to use HTTPRequest.asyncGet. My
question is how do I access Http status codes? I need it to handle
errors. The methods in HTTPRequest doesn't through any exceptions. The
interface ResponseHandler only provides the text response. Can I use
UncaughtExceptionHandler to get this?
My code looks as below..
HTTPRequest.asyncGet(URL, new ResponseTextHandler() {
public void onCompletion(String inResponseText) {
//How to get http status code
}
});
Please help.
Regards,
Krishna
if (!HTTPRequest.asyncGet(URL, new ResponseTextHandler() {
public void onCompletion(String inResponseText) {
}}) {
// handle error here
}
The docs say that HTTPRequest.asyncGet() returns false "if the
invocation fails to issue".
This is not what I want. Say the "URL is not found", the asyncGet would
still return true, and inResponseText would contain the html error page
from the web server..
Thanks,
Krishna
It looks like currently it is not possible to access the http status
code while invoking HTTPRequest.asyncGet. The methods in HTTPRequest
doesn't throw any exceptions. The interface ResponseHandler only
provides the text response.
HTTPRequest.asyncGet(URL, new ResponseTextHandler() {
public void onCompletion(String inResponseText) {
//Only way to check for error is by parsing the html.
}
});
It would be better if the onCompletion method in ResponseTextHandler
interface also provided the http status code.
Regards,
Krishna
I agree with the original poster. I know the JavaScript calls this
translates to allows for dealing with HTTP errors. However not being
able to from the GWT side is frustrating. I need my app to go back to
the login screen when the authentication token expires and my AJAX
requests start returning "FORBIDDEN" HTTP response.. There are just no
ways to detect errors without the HTTP error code. Regex the
responseText for "error" what if someone is searching my application
for "error" and that text is in the responseText of a properly served
request?
Thanks,
-Eric
On May 31 2006, 7:23 am, "Miguel Méndez" <mmen...@google.com> wrote:
> Hello Krishna,
>
> I could see how this could be useful for situations where you want to get
> additional information about the server's response. We appreciate your
> feedback.
>
> Thanks,
>
> On 5/30/06, krishna <krishnakum...@gmail.com> wrote:> Miguel Mendez
>
>
>
> > Hi chris,
>
> > This is not what I want. Say the "URL is not found", the asyncGet would
> > still return true, and inResponseText would contain the html error page
> > from the web server..
>
> > Thanks,
> > Krishna
>
> --
> GWT Engineer