dhalsim2
dhalsim2

Reputation: 963

favicon.ico for a REST-like web service using Tomcat

I have a REST-like web service that is deployed on Tomcat. There is no HTML in my servlet response; it's XML. I'd like to use my own favicon.ico instead of the Tomcat default.

If I place the file at webapps/myWebApp/favicon.ico, it doesn't load. I still get the Tomcat default. Going to http://localhost/myWebApp/favicon.ico shows that the file is indeed in place.

If I replace the file at webapps/ROOT/favicon.ico, then I get my new favicon. This isn't ideal because I'd like to package the favicon.ico in my war file and ideally wouldn't want other web apps to use my favicon.ico anyways.

Is there a better way to get my new favicon recognized?

For the record, I'm using Tomcat 7 and between each test, I restart Tomcat, clear my browser cache, and restart my browser.

Upvotes: 0

Views: 2312

Answers (1)

Christopher Schultz
Christopher Schultz

Reputation: 20862

That's not how "favicon" works: you either have to specify the URL of the favorite-icon to use (using <link rel="shortcut icon" href="http://example.com/myicon.ico" />) or put your favicon.ico file into the root of the server.

http://en.wikipedia.org/wiki/Favicon#Accessibility

So, since you are serving XML, you only have the one option.

Upvotes: 1

Related Questions