java - Browser navigates to webpage, but I get 500 error when using HttpURLConnection -


I must send a request for a webpage In the past, I used the HttpURL connection, and everything worked fine when I try to do the same thing at the moment, I get 500 return codes. Generally, this means there is a problem on the server, but I can actually paste the URL directly into a web browser, and I have no problem. (Browser is not loading cached version.)

  java.net.URL myURL = new java.net.URL (STRING_OF_URL_TO_BE_VISITED); Java.net.HttpURL Connection Connection = (java.net.HttpURLConnection) myURL.openConnection (); Connection.setRequestMethod ("GET"); Connection.setRequestMethod ("user-agent", "Mozilla / 5.0"); Connection.connect (); Integer response code = connection.getResponseCode (); String header item = ""; String header = ""; For (integer I = 0;; i ++) {header.cudi = connection.getHeaderFieldKey (i); HeaderItem = connection.getHeaderField (i); If (headers == empty) header = ""; Else headerKey + = ":"; If (headerEmv == blank) breaks; System.out.println (header + header item); }  

looks like a response header

  HTTP / 1.1 500 internal server error content-type: text / html; Charset = UTF-8 Content-Language: N-US Server: Microsoft-IIS / 7.5 Set Cookies: JSESSIONID = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; Path = / webapps / myWebApp; Secure X-appserver: myserver.mydomain.com P3P: CP = "CAO PSA Our" Date: Thursday, July 31, 2014 19:24:19 GMT Content-Length: 25912  

A co-worker thought that maybe the webpage was trying to redirect to another webpage, but I do not see a location line in the headline, so I do not know how it would be redirected.


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -