JSCH / NOTES</>↗JSch28 May 2025
When using JSch (Java Secure Channel) to connect to an SSH server, you can enable strict host key checking and validate the server against a known_hosts file. By default, strict host key checking ensures that your application will only connect to SSH servers that are already listed in the known_hosts file. If the server’s key […]
JSCH / NOTES</>↗JSch27 May 2025
When transferring files over SFTP using JSch, resuming partially transferred files (either uploads or downloads) can be implemented by handling offsets for files that are already partially transferred. This guide explains how to: Resume downloads by continuing from the last transferred byte of a local file. Resume uploads by appending to a remote file. Handling […]
HTTPCLIENT / NOTES</>↗HttpClient27 May 2025
Securing API requests with OAuth2 using Java 11’s HttpClient involves obtaining an access token from the OAuth2 provider and including it in the header of your HTTP requests. Here’s a step-by-step guide: 1. Understand OAuth2 Flow OAuth2 involves several flows (e.g., Authorization Code, Client Credentials, etc.). For simplicity, we’ll focus on the Client Credentials Grant […]
HTTPCLIENT / NOTES</>↗HttpClient26 May 2025
If you are using Java 11’s HttpClient and want to log request and response details, you can achieve this by implementing a custom utility. Java 11’s HttpClient provides flexibility to log and inspect both requests and responses using its APIs. Here’s how you can log them: Full Implementation for Logging Request and Response Below is […]
HTTPCLIENT / NOTES</>↗HttpClient26 May 2025
To parse JSON responses easily using Java 11’s HttpClient, you can use libraries like Jackson or Gson that help in converting a JSON string to Java objects (POJOs) without hassle. Here’s a step-by-step guide: Step 1: Create a Java 11 HttpClient request Use Java’s HttpClient to make an HTTP request and get the JSON response […]
HTTPCLIENT / NOTES</>↗HttpClient25 May 2025
Java 11 introduced the HttpClient API as part of java.net.http. By default, the HttpClient implementation provides connection pooling, so you don’t usually need to manually enable or build it. However, you do need to configure it effectively to manage connection pooling and ensure it aligns with your performance and scalability requirements. Here’s how you can […]