Sending leads from a site powered by Java

To send leads in from a lead form's backend code, you would generate a POST string and write that string to the desired POST URL.

For Example:

function DoPOST()
{
    String data = URLEncoder.encode("FirstName", "UTF-8") + "=" + URLEncoder.encode("John", "UTF-8");
    data += "&" + URLEncoder.encode("LastName", "UTF-8") + "=" + URLEncoder.encode("Doe", "UTF-8");
    data += "&" + URLEncoder.encode("Email", "UTF-8") + "=" + URLEncoder.encode("noemail@leads.com", "UTF-8");
    URL url = new URL("https://leads.leadexec.net/processor/insert/general");
    URLConnection conn = url.openConnection();
    conn.setDoOutput(true);
    OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
    wr.write(data);
    wr.flush();
    BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    String line;
    while ((line = rd.readLine()) != null) {
            // Process line...
    }
    wr.close();
    rd.close();
}
In the example above, the example POST string is first encoded and then is sent through the request stream to the POST URL. The response is then received and would then be processed to determined the desired action depending on the sending page's requirements and method sent to.


Copyright ©2024 ClickPoint Software