Java with Matlab for URL access...

homercles337

Diamond Member
Dec 29, 2004
6,340
3
71
Im using Java to do the bulk of the work for interfacing with a web server. We have a production server which is HTTPS, and a mirror development which is HTTP. Everything runs fine against the development HTTP server, but against the HTTPS server i get error code 302. Any ideas on how to fix this? I know little to no Java. This is the stacktrace:

Code:
??? Java exception occurred:
java.net.ProtocolException: Server redirected too many  times (20)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1496)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1490)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1144)
	at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
Caused by: java.net.ProtocolException: Server redirected too many  times (20)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1451)
	at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
	at java.net.HttpURLConnection.getResponseMessage(HttpURLConnection.java:445)
 

Doublejr

Senior member
Jul 25, 2004
205
0
0
It looks like the classes used are only for HTTP not HTTPS, just a quick glance at some docs shows java.net.httpsurlconnection is what should be used instead of java.net.httpurlconnection (this doesn't support https), httpsurlconnection extends httpurlconnection. Probably the other classes that have HTTP in their class name also.

So that may be it, not sure haven't worked with those classes.
 

homercles337

Diamond Member
Dec 29, 2004
6,340
3
71
Thats it. I should have posted that when i figured it out yesterday. Sometimes its better to think than google endlessly...