This tutorial is about how to highlight the currently active page in your navigation with Thymeleaf and Spring Boot. Highlighting the active page is a known usability pattern and should help users to find their way around your web application. Consider this example: In the navigation above, the navigation item “Cronjob Monitoring” is highlighted. The menu is generated with this Thymeleaf code: <nav class="mdl-navigation"> <a th:classappend="${#request.requestURI.startsWith(navItem.getLink()) ? 'mdl-navigation__link-active':''}" th:each="navItem: ${navigation}" th:id="${navItem.getIdentifier()}" class="mdl-navigation__link" th:href="@{${navItem.getLink()}}" th:text="${navItem.getName()}"></a> </nav> By using th:each, a link ...

Running regular background tasks on a network-attached storage (NAS) is an essential use case for backups, monitoring and more. With Synology DiskStations, there is an easy GUI-based approach to configure such tasks which still allows you to execute custom scripts. First, navigate to Control Panel > Task Scheduler: ...

In a blue-green deployment strategy, there are always two instances of your application running in production. A reverse proxy is used to direct traffic to either the green or the blue version. You then deploy changes to your application by first updating the inactive version and then changing the load balancer config to redirect traffic to the updated instance. In this video, I will show you how to set up a very simple version of such a blue-green deployment using ...

Sometimes I want to quickly save some code changes that I am not ready to commit into a real branch. For example, I might be in the middle of a long refactoring and there is a complete mess that I do not want to show up in version control history: Git has the “stash” command which removes all uncommitted changes and saves them to a local data structure where they can be retrieve later. However, this comes at the disadvantage ...

Zabbix is a great open source tool to monitor operating system and application metrics. You can install it on your web server and out of the box, it is able to show you fancy graphs for things like: Memory availability CPU usage Disk space usage Network bandwidth Free swap space In this guide, I will show you how to create a dashboard widget that displays the response time for a specific URL over time. You can use this to monitor ...

Learn how to add HTTPS encryption to your Spring Boot application running inside a Docker container. Since the arrival of free Let’s Encrypt certificates, there is really no excuse not to use HTTPS for encrypting your application traffic. Obtaining and integrating a free HTTPS certificate is easy and only requires three simple steps. This article shows the integration for a CentOS 8 web server with a Dockerized Spring Boot application. Registering a Certificate On your web server, obtain certbot, the ...

Ignoring the semantics of HTTP methods such as GET and POST can have disastrous security repercussions. You might think that using GET methods for deleting entities is fine since you only need to pass a single identifier and do not want to set up its own HTML form for doing so. Please let me convince you of the opposite. HTTP Semantics Before we can go into detail why this distinction matters for web application security, we need to grasp the ...

In this article, I will demonstrate how to install Java OpenJDK 14 on macOS Catalina in 2020. If you are interested in installing OpenJDK 15 (which is the newest version as of this writing), please see this article: How to Install Java OpenJDK 15 on macOS Catalina Download and Install OpenJDK 14 Download the .tar.gz version of OpenJDK 14 from jdk.java.net/14/. sudo mv openjdk-14.0.1_osx-x64_bin.tar.gz /Library/Java/JavaVirtualMachines/ cd /Library/Java/JavaVirtualMachines/ sudo tar -xzf openjdk-14.0.1_osx-x64_bin.tar.gz sudo rm openjdk-14.0.1_osx-x64_bin.tar.gz Next, execute the following command to ...

In this post, I am showing you how to use the freely available Open Weather Map API to retrieve hourly weather forecasts 48 hours into the future for a given place using Python without external packages. Continue reading if you need an easy and flexible way to obtain weather data in your python application and you want to avoid using third-party dependencies for the task. You will use the free tier of the Open Weather Map API. The resulting weather ...

Flash messages (one-time notifications) are commonly used to display the result of an operation to your users: Spring Boot offers this exact functionality in the RedirectAttributes interface. It uses the FlashMap data structure to store the flash messages as key-value pairs. Thymeleaf automatically supports reading those attributes in the template files the same way it handles ordinary model attributes. One handy feature of flash messages is that they survive redirects (in contrast to normal model attributes). Have a look at ...

Bernhard Knasmüller on Software Development