• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

HttpURLConnection & Exceptions

 
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to use the method getResponseCode() with HttpURLConnection in a client.
I have setup my server to return a 404 - file not found when I hit a certain page on the server for testing.
Thing is, the client code seems to be throwing a FileNotFound exception when I call the getResponseCode() method instead of returning a value.
I'm catching the exception, but this is not really what I want.
Any ideas? Did I forget to set something?
Thanks,
Drew
 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Show the actual code. From reading your message it sounds like you're simply calling getResponseCode() and that throws FileNotFoundException. According to the javadoc, it can throw IOException, but I don't think it would throw that particular type of IOException (FileNotFoundException), so I think the exception may be coming from a different piece of code.
 
Drew Lane
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I took a look at the javadoc, too.
It does say that a FileNotFoundException should be thrown when a 404 is returned by the server. So, I guess the behaviour is correct. Not what I expected, however...
Now it looks like I'm having some issues with this because it does not seem to be implemented the same across certain platforms.
Heh.
Drew
 
We don't have time for this. We've gotta save the moon! Or check this out:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic