Note: Advice in this article will only work for JxBrowser 6. See the corresponding article for JxBrowser 7 here.

JxBrowser API provides functionality that allows accessing and modifying POST/PUT/PATCH upload data before it will be sent to a web server. POST/PUT/PATCH upload data can be one of the following types:

Depending on the upload data type, you can use different strategies for accessing and modifying upload data. The following sample demonstrates how to do this:
import com.teamdev.jxbrowser.chromium.*;
import com.teamdev.jxbrowser.chromium.swing.DefaultNetworkDelegate;

 * This sample demonstrates how to read and modify POST data of
 * HTTP request using NetworkDelegate.
public class POSTDataSample {
    public static void main(String[] args) {
        Browser browser = new Browser();
        BrowserContext browserContext = browser.getContext();
        NetworkService networkService = browserContext.getNetworkService();
        networkService.setNetworkDelegate(new DefaultNetworkDelegate() {
            public void onBeforeURLRequest(BeforeURLRequestParams params) {
                if ("POST".equals(params.getMethod())) {
                    UploadData uploadData = params.getUploadData();
                    UploadDataType dataType = uploadData.getType();
                    if (dataType == UploadDataType.FORM_URL_ENCODED) {
                        FormData data = (FormData) uploadData;
                        data.setPair("key1", "value1", "value2");
                        data.setPair("key2", "value2");
                    } else if (dataType == UploadDataType.MULTIPART_FORM_DATA) {
                        MultipartFormData data = (MultipartFormData) uploadData;
                        data.setPair("key1", "value1", "value2");
                        data.setPair("key2", "value2");
                        data.setFilePair("file3", "C:\\");
                    } else if (dataType == UploadDataType.PLAIN_TEXT) {
                        TextData data = (TextData) uploadData;
                        data.setText("My data");
                    } else if (dataType == UploadDataType.BYTES) {
                        BytesData data = (BytesData) uploadData;
                        data.setData("My data".getBytes());
                    // Apply modified upload data that will be sent to a web server.
        browser.loadURL(new LoadURLParams("http://localhost/", "key=value"));