• Post Reply Bookmark Topic Watch Topic
  • New Topic

HttpURLConnection & Exceptions  RSS feed

 
Drew Lane
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • 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
 
Billybob Marshall
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!