Author: Editorial Team
-
Reverse a List in Java
Assume a List<T> list: Approach 1: Using Streams (Index-based mapping) Approach 2: Using Collections.reverse() (Recommended for mutable lists)
-
Count Words in a String Using Java Streams
Assume a String text: Approach 1: split() + groupingBy Approach 2: Pattern + Matcher.results() (Unicode-aware, Java 9+)
-
Remove Duplicates from a List by Field in Java
Assume an Employee class with an id field: Approach 1: Using toMap() (Keeps first occurrence) Approach 2: Using TreeSet with Comparator (Keeps first per comparator) Summary:
-
Java ClassLoaders
Java ClassLoaders are one of the most important, yet often misunderstood, components of the Java Runtime Environment (JRE). Understanding ClassLoaders helps in building modular applications, dynamic frameworks, and secure enterprise systems. At a high level, ClassLoaders are responsible for loading classes into JVM memory at runtime. Without class loaders, the JVM would not know how…
-
Class Loading in Java
1. What is Class Loading in Java? In Java, class loading is the process by which the Java Virtual Machine (JVM) loads classes and interfaces into memory at runtime. Unlike some languages that load all code upfront, Java uses a dynamic loading mechanism, meaning classes are loaded only when they are first referenced or needed.…
-
How to Change the Embedded Server in Spring Boot
1. Exclude Tomcat By default, spring-boot-starter-web brings in Tomcat. To use a different server, you must exclude Tomcat from it. In Maven, this looks like: 2. Add the Alternative Server Dependency Choose only one of the following: a. Use Jetty b. Use Undertow c. Use Netty (only for reactive applications) If you’re using spring-boot-starter-webflux, Netty…
-
How to Invalidate Compromised JWT Tokens in Keycloak
1. Force Logout a User from Keycloak Admin Console When you know that only a specific user’s token is compromised, you can invalidate their session manually from the Keycloak Admin Console. Steps: What It Does: Why It’s Useful: 2. Logout All Sessions of the User This option is useful if the user is logged in…
-
What Information Can Be Seen in a JWT?
1. Introduction A JWT (JSON Web Token) is a compact, URL-safe token format used for securely transmitting information between parties. It’s widely used in modern applications for authentication and authorization. A JWT is composed of three parts: All three parts are Base64URL-encoded strings, separated by periods (.). While the signature part is cryptographically secure and…
-
JWT Claims
JWT Claims are the core data that a JWT token carries. These claims convey specific statements about a subject (e.g., a user), and are encoded in the Payload section of a JWT. 4.1. JWT Claims Set The JWT Claims Set is a JSON object containing a collection of name/value pairs called claims. These claims assert…
-
JSON Web Token (JWT) – An Introduction
1. Introduction JSON Web Token (JWT) is a lightweight, compact, and URL-safe way to represent a set of claims between two parties. It’s especially useful in environments where bandwidth or storage is limited, such as: JWTs are typically used in web authentication and authorization flows. They allow claims (such as user identity or roles) to…
