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();
            OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());

            // Get the response
            BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String line;
            while ((line = rd.readLine()) != null) {
        catch (Exception e) {

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.

This article has been dead for over six months. Start a new discussion instead.