I can find some jars like HTMLPARSER and java.net package to access the source of a URL

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

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

String data=null;
URL location = new URL("http://www.google.com");
URLConnection conn = location.openConnection();
BufferedReader in = new BufferedReader(
    new InputStreamReader(
    conn.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) 
    data += inputLine + "\n";
System.out.println(data);
in.close();
    }
}

How can we access source code of a web URL that can be accessed only if we have logged in? For example how to access my gmail inbox contents url from java?
How should i pass the login credentials?

You can use HttpClient, see tutorail here

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.