I need to log in to a website with Java, its an https(SSL) site. I have some code that doesn't give me an error but it doesn't log in. I've tried a similar program in python and it didnt login either. I think I'm missing some basic concept about this... What am I doing wrong?

package zangle;

import java.io.*;
import java.net.*;

public class Zangle {

    public static void main(String[] args) {
        try {
            // Construct data
            String data = URLEncoder.encode("stuident", "UTF-8") + "=" + URLEncoder.encode("username", "UTF-8");
            data += "&" + URLEncoder.encode("stupassword", "UTF-8") + "=" + URLEncoder.encode("password", "UTF-8");

            // Send data
            URL url = new URL("https://webconnect.bloomfield.org/Zangle/StudentConnect/logincheck.aspx");
            URLConnection conn = url.openConnection();
            conn.setDoOutput(true);
            OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
            wr.write(data);
            wr.flush();

            // Get the response
            BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String line;
            while ((line = rd.readLine()) != null) {
                System.out.println(line);
            }
            wr.close();
            rd.close();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}

make sure that you are connected to the server

make sure that you are connected to the server

It displays the entire html of the page, so I know it connected. The problem is it shows the html of the login page, not the page after it logged in.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.