HttpsURLConnection problem:Server redirected too many times

L

Lukasz

Dzien dobry

Mam nastepujacy kod w Javie, powinien on suzyc do polaczenie sie ze
strona action przez https i
przeslanie loginu i hasla, niestety po uruchomieniu dostaje komunikat
java.net.ProtocolException: Server redirected too many times (20)
.. Nie wiem dla czego sie tak dzieje, moze zrobilem cos zle. Czy zna
ktos moze przycznye wystapienia tego bledu
i wie jak go usunac ? Dzieki za wszelka pomoc




import java.net.*;
import java.io.*;
import javax.net.ssl.*;
import java.security.*;
import com.sun.net.ssl.HttpsURLConnection;


public class sklep {

public static void main(String[] args){

int port=443;
String host="i-serwis.action.pl";

try{

System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
SSLSocketFactory factory=(SSLSocketFactory)SSLSocketFactory.getDefault();

URL u = new URL("https://i-serwis.action.pl/login.php");
HttpsURLConnection https = (HttpsURLConnection)
u.openConnection();
https.setSSLSocketFactory(factory);
https.setRequestMethod("POST");
https.setRequestProperty(
"Content-Type","application/x-www-form-urlencoded" );
https.setDoOutput(true);
https.setDoInput(true);
OutputStreamWriter out =new OutputStreamWriter(new
BufferedOutputStream(https.getOutputStream()),"8859_2");

String query = "customerid=" + URLEncoder.encode("") + "&";
query += "username=" + URLEncoder.encode("user") + "&";
query += "userpasswd=" + URLEncoder.encode("haslo");
out.write(query, 0, query.length());
out.flush();
out.close();

https.disconnect();


}
catch (IOException e){
System.err.println("Blad:"+e);
}

}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

SSL client program 20
dynamiczna alokacja pamieci 1

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top