23

Does anyone know how to implement a favicon icon for a particular application using Tomcat? This icon file would not be for all webpapps, just this one on the server in question.

Mr Morgan
  • 307
  • 3
  • 5
  • 13

4 Answers4

32

Just add the following code in the <head> to your index.html in you webapp/projectName/

<link rel="shortcut icon"
 href="http://example.com/myicon.ico" />
Adnan
  • 25,882
  • 18
  • 81
  • 110
  • 5
    The best thing is to name it favicon.ico and put it in your root folder, as many browser will automatically apply it. – Adnan Aug 12 '11 at 12:42
  • 2
    I added my favicon.ico file to the 'web' file folder in my NetBeans 7.2 project (web app) which is deployed to TomEE 1.5.1 SNAPSHOT (tomcat version 7.0.33 at the time I'm writing this comment), and after accessing the web app via Google Chrome browser, I did not see my favicon.ico; I see tomcat's favicon.ico on the browser tab. I even did a refresh (F5 key), and i still see tomcat's favicon.ico on the browser tab. I'm about to try the recommended in this answer. – Howard Dec 07 '12 at 03:09
12

I like to add that the original tag type for the link was "shortcut icon", but that didn't conform to the standard so it was sort of switched to "icon".

So I recomend add both to your head block:

<link rel="icon" href="http://www.example.com/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="http://www.example.com/favicon.ico" type="image/x-icon"> 

Also some browsers don't support sizes other than 16px X 16px.

belyid
  • 841
  • 2
  • 12
  • 28
9

Delete or rename tomcat/webapps/ROOT/favicon.ico and Tomcat will look for a favicon.ico in the root of each web app that it serves. You don't need to put a into the head section of each page.

Trevor Turton
  • 231
  • 3
  • 2
4
<link rel="shortcut icon" href="http://example.com/myicon.ico" />

add that within the <head> of your page - where the .ico file is an icon - there are several websites (use google) that generate .ico files from pictures (gif / jpeg etc)

Manse
  • 37,765
  • 10
  • 83
  • 108