title: How to Automate login to a webpage using jsoup in android?
body: <p>I was trying to make an automatic login for my users to <a href="http://www.bvrit.edu.in" rel="nofollow noreferrer">http://www.bvrit.edu.in</a> using jsoup and the display the logged in web page for my users using a webview.I added the jsoup API,checked using inspect elements that the id of the usename field is txtId1 and password is txtPwd1 and replace data in post with the respective names.I also added the internet access permission to manifest but i am not able to display the webpage my code is as shown below,i think i am getting some basics wrong but had not been able to figure it out.</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState)  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  }
  
  public void main(String[] args) throws IOException {
  
      WebView browser = (WebView) findViewById(R.id.bvritWebview);
  
      Connection.Response loginForm = Jsoup.connect("http://www.bvrit.edu.in/")
              .ignoreContentType(true)
              .userAgent("Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0")
              .referrer("http://www.google.com")
              .timeout(12000)
              .followRedirects(true)
              .method(Connection.Method.GET)
              .execute();
  
      Connection.Response loginFormFilled = Jsoup.connect("http://www.bvrit.edu.in/")
              .ignoreContentType(true)
              .userAgent("Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0")
              .followRedirects(true)
              .referrer("https://login.to/")
              .data("txtId1", "username")//check the form to find field name for user name
              .data("txtPwd1", "password")//check the form to find field name for user password
              .cookies(loginForm.cookies())
              .method(Connection.Method.POST)
              .execute();
      int statusCode = loginFormFilled.statusCode();
      Map&lt;String, String&gt; cookies = loginFormFilled.cookies();
      browser.getSettings().setJavaScriptEnabled(true);
      browser.loadUrl("http://www.bvrit.edu.in");
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>header section of the networking after logigng in-
  <a href="https://i.stack.imgur.com/fVDzk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fVDzk.png" alt="enter image description here"></a></p>