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");


Leave a Reply

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


* Copy This Password *

* Type Or Paste Password Here *

68,488 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>