https://issues.apache.org/bugzilla/show_bug.cgi?id=51197
--- Comment #8 from Konstantin Kolinko <knst.koli...@gmail.com> 2012-02-21 17:17:06 UTC --- (In reply to comment #7) > You have to use URLConnection.getErrorStream if the response code is > "problematic". I have this code in a class that fetches data from an HTTP > server: > > int responseCode = conn.getResponseCode(); > > boolean error = 5 == responseCode / 100 > || 4 == responseCode / 100; > > if(error) > in = new BufferedInputStream(conn.getErrorStream()); > else > in = new BufferedInputStream(conn.getInputStream()); > > Then I just use "in" as I please. > Thank you! Good advise. > > Caused by: java.io.IOException: Server returned HTTP response code: 400 for > > URL: http://localhost:3596/asyncErrorServlet > > at > > sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436) > > at > > java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379) > > at > > org.apache.catalina.startup.TomcatBaseTest.getUrl(TomcatBaseTest.java:232) > > ]]] > > Weird that it's throwing an exception from getResponseCode. What JRE are you > using? 6u31. getResponseCode() call cashes the exception but does not return it. Then subsequent call to getInputStream() wraps this original exception as the cause. -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org