Convert XML to HTML using XSLT in Java

In this post I will show you how to convert XML to HTML using XSLT in Java using Saxon HE version 11 library We will add the dependency to our pom: Our sample XML will be: The XSLT we will be using to convert the XML into HTML is: Following are the steps to process … Read more

Integrate with OpenAI(ChatGPT) Chat Completion API in Java using Webclient

In my previous post I showed how you can integrate with Completion API. The completion API doesnt support the ChatpGPT model. The ChatGPT model is supported in the Chat completion API. In this post we will look at integrating with this new API using WebClient. Below are the POJOs we will be using for parsing … Read more

Java 17 – Sealed classes

Prior to Sealed Classes feature there were two ways a developer could prevent a class to be extended: by declaring the class as final where no one can extend this class. 2. by making the class package private where no one outside the package can access the class and hence no one outside the package … Read more

Java 16 – Records and Constructor

In my previous post, I introduced you to the new construct called Records which was introduced in Java 16. In this post, I will go a bit deeper into how you can override the default constructor of a record which is different from the no-arg default constructor of a class. Default constructor in a record … Read more

Java 16 – Records

We all, Java programmers, have complained whenever we were forced to create a class or use maps just to hold some data whilst other newer languages provided some out-of-the-box data structure for the same. Our problem has been addressed by introducing “Records” as part of the JEP 395 in Java 16. This construct is introduced … Read more

Difference between Function.andThen and Function.compose

There are two different ways to mix functions in Java: using andThen using compose It is important to understand the difference between the two. andThen: function1.andThen(function2) will first apply function1 to the input and the result of this will be passed to the function2. compose: function1.compose(function2) will first apply the input to the function2 and … Read more

Sample Logback Configuration for Spring Boot Profile Based Logging

We would want different logging configurations for different profiles in Spring Boot, like in local running we would just want console logging and for production, we would want file logging with support for rolling the log files daily. I came up with a sample logback configuration which I use in all my applications. Create a … Read more

Getting to know about java.nio.file.Path – 2

In Part 1 of this, we looked at most of the APIs in the java.nio.file.Path class. In this article, we will look at the remaining APIs. Using register() This API allows us to register an implementation of java.nio.file.WatchService interface which will listen for events like directory creation, modification, and deletion. And it intimates the listeners … Read more

Getting to know about java.nio.file.Path – 1

Introduction The last few released of Java namely Java 7, Java 8 and the upcoming Java 9 have quite a lot of features which makes the life of Java developers easier. (I know Java 9 will make it tougher, but only while you adopt the new paradigm. After that it’s going to be much better). … Read more

Gotcha: Migrating from Spring Security 3.2.x to Spring Security 4.x

Here is a simple gotcha to keep in mind while migrating to newer Spring Security version 4.x from Spring Security 3.2.x What’s the problem? The Spring security configuration expressions hasRole(‘role_name’) and hasAuthority(‘role_name’) are no longer the same. The catch is: hasAuthority checks for any role name passed to the expression without prepending ‘ROLE_’ (which is … Read more

%d bloggers like this: