Sample code for 30+ languages & platforms
Java

Demonstrate HttpRequest.RemoveAllParams

Demonstrates the effect of calling HttpRequest.RemoveAllParams.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.HttpRequest;

public class ChilkatExample {

    public static void main(String[] args) {
        HttpRequest req = new HttpRequest();

        req.setHttpVerb("POST");
        req.setPath("/test123");
        req.setContentType("application/x-www-form-urlencoded");
        req.addParam("paramA", "AAA");
        req.addParam("paramB", "BBB");
        req.addParam("paramC", "CCC");

        System.out.println(req.generateRequestText());
        System.out.println("---------------");

        // Generates:

        //     POST /test123 HTTP/1.1
        //     Content-Type: application/x-www-form-urlencoded
        //     Host: domain
        //     Content-Length: 32
        //
        //     paramA=AAA&paramB=BBB&paramC=CCC
        //

        // If we call RemoveAllParams, and then add some additional params,
        // then the original params are gone, and only the new params exist.
        req.removeAllParams();
        req.addParam("paramD", "DDD");
        req.addParam("paramE", "EEE");
        req.addParam("paramF", "FFF");
        System.out.println(req.generateRequestText());
        System.out.println("---------------");

        // Generates:

        //     POST /test123 HTTP/1.1
        //     Content-Type: application/x-www-form-urlencoded
        //     Host: domain
        //     Content-Length: 32
        //
        //     paramD=DDD&paramE=EEE&paramF=FFF
    }
}