Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedded Jetty and favicon

I am using Jetty embedded in my application as follows:

    ResourceConfig rc = new PackagesResourceConfig("my.jersey.resources.package");
    ServletHolder servletHolder = new ServletHolder(new ServletContainer(rc));
    ServletContextHandler servletContextHandler =
            new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS);
    servletContextHandler.addServlet(servletHolder, "/" + customContextPath + "/*");
    server.start();

Is there any way for me to add some kind of handling for a custom favicon.ico using the aforementioned setup?

Thanks

like image 262
gpol Avatar asked Apr 26 '13 11:04

gpol


People also ask

What is embedded Jetty?

Put another way, running Jetty in embedded mode means putting an HTTP module into your application, rather than putting your application into an HTTP server.

What is Jetty used for?

Jetties protect the shoreline of a body of water by acting as a barrier against erosion from currents, tides, and waves. Jetties can also be used to connect the land with deep water farther away from shore for the purposes of docking ships and unloading cargo. This type of jetty is called a pier.

What is Jetty and jersey?

Jersey is an open source framework for developing RESTful Web Services in Java. It is a reference implementation of the Java API for RESTful Web Services (JAX-RS) specification. Jetty is a Java HTTP (Web) server and Java Servlet container.

Is Jetty asynchronous?

Jetty has good support for asynchronous request processing.


2 Answers

Just adding the favicon.ico to the root directory doesn't work because the browser doesn't include the app's context when fetching the favicon. Add this to your HTML:

<link rel="shortcut icon" href="images/favicon.ico">

Be sure to provide a correct absolute or relative path to your favicon.

like image 69
Don Branson Avatar answered Sep 28 '22 06:09

Don Branson


Have you tried adding favicon.ico to the root directory of where your content is located.

like image 21
Ayub Malik Avatar answered Sep 28 '22 07:09

Ayub Malik