Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / November 2005

Tip: Looking for answers? Try searching our database.

URLConnection - status?

Thread view: 
John Mowbray - 01 Nov 2005 10:05 GMT
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 - 01 Nov 2005 11:28 GMT
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.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Roedy Green - 01 Nov 2005 11:38 GMT
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.

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

John Mowbray - 01 Nov 2005 12:27 GMT
My bad - you're absolutely right, I had been confusing URLConnection
with HttpURLConnection.

> On Tue, 1 Nov 2005 09:05:29 +0000 (UTC), John Mowbray
> <jmowbray2003@hotmail.com> wrote, quoted or indirectly quoted someone
[quoted text clipped - 19 lines]
> HttpURLConnection.HTTP_NOT_FOUND are constants used to fake enums or
> represent numbered error messages.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.