Search code examples
eclipsetomcaturl-routingfavicon

How to provide a favicon to a Tomcat webapp which is not served on root in order to avoid browser's 404s on /favicon.ico


For an intranet project I have a Tomcat serving a website under http://myserver.local:1234/boilergraphs/index.html

I develop new features for this webapp in Eclipse. For debugging I am using heavily the Web Developer Tools of the external browsers Chrome and Firefox. Both browsers test automatically for http://myserver.local:1234//favicon.ico - and give me 404 errors in the developer console due to the fact that the URL doesn't exist. This console output is quite distracting because I watch the console for other, development-related errors.

How can I tell my Tomcat instance (inside Eclipse) to serve a favicon.ico on http://myserver.local:1234/favicon.ico, while the only app on the Tomcat system is the boilergraphs app?


Solution

  • You can't if the only app is your boilergraphs app. You'll need to have a second web app with your favicon.ico file, to open the server editor for your instance in the Servers View, and deploy the other web app to a path of /. Tomcat itself ships with such an app in its webapp/ROOT folder.

    Server instance context menu in the Servers View

    Modules page in the Server editor, showing a second app deployed to /