Author: Vijay SRJ

  • Java 15 features every Java developer should know

    Java 15 just arrived. There were in total 14 features introduced in this release. But not every feature needs to be understood from a developer perspective. Only 4 of the 14 features are must to know features for java developers to utilize in their java applications. Here are those four: Sealed classes Text blocks Records…

  • How to structure a website / HTML document?

    There is so much you can display on a HTML document. You can give a header to the entire document. You can have a navigation bar to navigate among different pages. You can have a side bar where you can display your blog posts list. You can show an article as the main content. All…

  • How to accept user data in a HTML document?

    HTML is used not only to display data but also to accept user input. This input then can be sent to a server or processed through javascript within the document. Input Types So what are the ways HTML allows user to provide input? You can type in a text: That is represented by the below…

  • How to use HTML head?

    Every HTML has a head tag . This is the first tag. What is this for? To provide meta data (data about data) about the HTML document you are going to create . What is the title of this document? Who is the author of this document? What set of characters are allowed in this…

  • What is HTML ?

    Let’s say you are new to the internet. You just know that you can connect to the internet through a browser. Some one told you that “information” exists on a place called “server” and you can see them through a magical tool called “browser”. So if you want some information from the internet you use…

  • How to use Window functions in SQL?

    SQL has evolved a lot since its widely adopted standard SQL-92. Most of the queries which developers use belong to this standard. It represents the relational database model. Markus Winand of modern-sql.com says SQL has grown five times since that standard and SQL is not just a relational database model anymore. You can store JSON…

  • What are the different ways to delete a child entity in JPA/hibernate through Spring Data?

    Let’s say you have an application which creates blog posts and saves them and also the comments user enter on the posts. The Blogpost and the comment represent a parent and child relationship. You may want to delete the comments in three different ways: Delete the comment whenever the blogpost is deleted. Delete the comment…

  • How to save both parent and child records on saving parent record in JPA/hibernate?

    Let’s say you have created an application to post blogs. You are allowing users to comment on the blogs. Every blog is associated with many comments. You have chosen spring data as your backend technology. How would you design this ? You can create an entity class representing a blog post , say Blogpost.java And…

  • How and when to use computeIfPresent() and computeIfAbsent() methods of Map interface in Java?

    Let’s assume you are developing a java app to keep score of goal scores of football players. Every time a player scores a goal , you call a method with the name of the player and the score gets incremented for that player. What data structure would you choose for this? Ideally a map with…

  • How to log IP addresses of incoming requests to a Spring Boot app in a centralized way?

    Let’s say you want to track the source of hits coming to your REST services. And you have developed them using Spring Boot. Here is the algorithm: STEP1: Create a Spring Handler Interceptor STEP2: Retrieve the IP address in the prehandle method of the Handler interceptor. 2.a) Use X-Forwarded-For header extracted from HttpRequest object to…