How to show custom favicon in Vaadin UI ?

Add this custom Vaadin servlet to show a different favicon (other than the Vaadin default) in your UI application –


import com.vaadin.server.*;
import com.vaadin.spring.server.SpringVaadinServlet;
import org.springframework.stereotype.Component;
import javax.servlet.ServletException;

public class CustomServlet extends SpringVaadinServlet {

protected void servletInitialized() throws ServletException {

getService().addSessionInitListener((SessionInitListener) event -> event.getSession().addBootstrapListener(new BootstrapListener() {

public void modifyBootstrapFragment(
BootstrapFragmentResponse response) {
// TODO Auto-generated method stub


public void modifyBootstrapPage(BootstrapPageResponse response) {
getElementsByAttributeValue("rel", "shortcut icon").attr("href", "./images/favicon.png");
.getElementsByAttributeValue("rel", "icon")
.attr("href", "./images/favicon.png");



Kj [/.] Sreekumar programs computers as a hobby and profession. Into programming from his school days, Sree uses Codemarvels to key in facts and fixes he finds interesting while working on different projects. Some of the articles here give away a few shades of his philosophical leanings too.

Leave a Comment

Your email address will not be published. Required fields are marked *