How to post form login using jsoup?

The URL that are you using in order to do the POST request is wrong, simply because when you have to do a specific request to a form you should use the web page that is present in the form tag, in this case “authentication.php”.

So the code will be:

    package jsouptest;

    import org.jsoup.Connection;
    import org.jsoup.Jsoup;
    import org.jsoup.nodes.Document;

    public class JsouptTest {
        public static void main(String[] args) throws Exception {

           Connection.Response loginForm = Jsoup.connect("")

           Document document = Jsoup.connect("")
            .data("cookieexists", "false")
            .data("username", "32007702")
            .data("login", "Login")



This one correctly retrieves the web page that you want.

Leave a Comment