Home > Archive > Java Help > November 2005 > URLConnection - status?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
URLConnection - status?
|
|
| John Mowbray 2005-11-01, 3:58 am |
| Can't seem to find how to get the status of a connection under Java 2
5.0. Under 1.4.2 there were all sorts of static ints to give you this
info, but 5.0 only has a single protected boolean flag. Short of going
back to 1.4.2, does anyone know how to get the status? e.g. is it a
404-page not found error?
John
| |
| Roedy Green 2005-11-01, 8:02 am |
| On Tue, 1 Nov 2005 09:05:29 +0000 (UTC), John Mowbray
<jmowbray2003@hotmail.com> wrote, quoted or indirectly quoted someone
who said :
>Can't seem to find how to get the status of a connection under Java 2
>5.0. Under 1.4.2 there were all sorts of static ints to give you this
>info, but 5.0 only has a single protected boolean flag.
What classes are you talking about? I have never known Sun yet to
drop a method or field. They deprecate them.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
| |
| Roedy Green 2005-11-01, 8:02 am |
| On Tue, 1 Nov 2005 09:05:29 +0000 (UTC), John Mowbray
<jmowbray2003@hotmail.com> wrote, quoted or indirectly quoted someone
who said :
>Can't seem to find how to get the status of a connection under Java 2
>5.0. Under 1.4.2 there were all sorts of static ints to give you this
>info, but 5.0 only has a single protected boolean flag. Short of going
>back to 1.4.2, does anyone know how to get the status? e.g. is it a
>404-page not found error?
The object you have is likely a java.net.HttpURLConnection
or HttpsURLConnection or JarURLConnection.
Look at methods in those classes. e.g
..HttpURLConnection.getResponseCode.
You could not possibly store info about a connection in a static
field. That has to go in instance fields, otherwise how would you
know which socket it applied to?
the static ints you are likely thinking of, e.g.
HttpURLConnection.HTTP_NOT_FOUND are constants used to fake enums or
represent numbered error messages.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
| |
| John Mowbray 2005-11-01, 8:02 am |
| My bad - you're absolutely right, I had been confusing URLConnection
with HttpURLConnection.
Roedy Green wrote:
> On Tue, 1 Nov 2005 09:05:29 +0000 (UTC), John Mowbray
> <jmowbray2003@hotmail.com> wrote, quoted or indirectly quoted someone
> who said :
>
>
>
>
> The object you have is likely a java.net.HttpURLConnection
> or HttpsURLConnection or JarURLConnection.
>
> Look at methods in those classes. e.g
> .HttpURLConnection.getResponseCode.
>
> You could not possibly store info about a connection in a static
> field. That has to go in instance fields, otherwise how would you
> know which socket it applied to?
>
> the static ints you are likely thinking of, e.g.
> HttpURLConnection.HTTP_NOT_FOUND are constants used to fake enums or
> represent numbered error messages.
>
>
>
|
|
|
|
|