Posts about Java

Date HTTP header formatting

November 29th 2024 .NET Java

As we were implementing date formatting for the Date HTTP header in .NET, a Java developer warned us to double-check if we really want to use the built-in RFC 1123 format specifier for that. It turned out it is safe to do so in .NET, but you really shouldn't use the Java RFC 1123 formatter in this case.

Generate URLs for Internal Links in Hippo

June 7th 2019 Hippo CMS Java

Hippo CMS treats internal links differently from external ones. Even when they are a part of an HTML field in a content document, they are stored as a reference to the referred content document and not as a regular hyperlink. When you're using the hst:html tag for rendering HTML fields in the template, it will take care of that automatically. But if you want to use the raw HTML string in some other way, the internal links inside it won't be valid.

Folder Picker in a Hippo CMS Component

May 31st 2019 Hippo CMS Java

Hippo CMS has built-in support for configuring components through auto-generated dialogs in the Channel Editor. These can easily be defined by using annotations in the component's ParametersInfo interface. Although there's an option to open a document picker, the documentation only hints at different configurations for it. After reading, it wasn't clear how to use it for picking a content folder instead of a document.

Exclude a URL from Being Served by Hippo CMS

March 22nd 2019 Hippo CMS Java

In a Hippo CMS site, all URLs are under its control. Using the sitemap configuration, you can to some extent influence how URLs will map to content but there's no obvious or well-documented way to make Hippo CMS ignore the URL and let it be processed by a different servlet.

Unicode Properties Files in IntelliJ IDEA

November 16th 2018 IntelliJ IDEA Java

In Java, .properties files are by default saved in ISO-8859-1 encoding. Since many languages use characters not included in this encoding, these characters will need to be expressed using Unicode escape sequences. Fortunately, IntelliJ IDEA can automatically handle conversion between the Unicode literals and their corresponding escape sequences, but the feature is not enabled by default.

Handling Empty POST Response in Hippo CRISP

October 19th 2018 Hippo CMS Java

One could argue that a JSON REST service should never return an empty body, but you might not always have a say in how a service you need to call will behave. Unfortunately, CRISP API in Hippo CMS throws a NullPointerException if the response body is empty.

Jackson ObjectMapper Config in Hippo CRISP

October 12th 2018 Hippo CMS Java Spring

The recommended way for integrating external services in Hippo CMS is the CRISP API. The official documentation provides detailed enough instructions for installing, configuring and using it. However, when I needed to customize the default Jackson ObjectMapper, it wasn't all that obvious how I could do it.

Initializing Log4j MDC in Hippo CMS

October 5th 2018 Hippo CMS Log4J Java Spring

In Log4j, Mapped Diagnostic Context (MDC) can be used to provide additional context information for every log message. In server applications it will usually be initialized for every request in a filter. In Hippo CMS, a custom valve must be injected into the request pipeline for that purpose.

Implementing Basic Authentication with CXF

September 7th 2018 Apache CXF Java

Generating the proxy client classes for a web service is only the first step. While the official documentation includes a basic sample for invoking a method on the web service, I had a hard time finding any guidance on how to pass in the credentials for basic authentication.

Code Generation with Maven CXF Plugin

August 31st 2018 Apache CXF Maven Java

Apache CXF is a common choice for calling SOAP web services from Java. It's most convenient to use when you generate proxy client classes from the web service WSDL file. There's a command line tool available for that but if you don't want to put the generated sources in source control, you'll probably prefer the Maven plugin.

Linking a Document to a Hippo Component

March 9th 2018 Hippo CMS Java

Most built-in components in Hippo CMS have a link to one or more documents as they are designed to render the CMS content documents. Sooner or later you'll want to achieve that with your own custom component as well.

Web Component Component for Hippo CMS

March 2nd 2018 Hippo CMS Web Components Java

As a part of getting acquainted with Hippo CMS I took on the task of creating a custom Hippo component for including a Stencil web component in a portal page using the CMS editor. I based my work on a similar component I found on GitHub for a Polymer web component.

Tree Fractal

August 3rd 2001 Java

Tree Fractal applet interactively demonstrates how easy it is to construct interesting images by adjusting the fractal parameters. The archive contains complete source code, a jar archive with compiled classes and a HTML page for viewing in a browser.

Java Classes

February 3rd 2001 Java 3D Java

There probably isn't a computer user out there who hasn't heard of Java before. The language is already shipped with many ready to use classes and every release has more of them. I have written classes for some common tasks myself and you can download them from here for free.