tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Favicon for resources when using multiple webapps
Date Fri, 04 Nov 2016 22:31:55 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Rebecca,

On 11/3/16 4:16 PM, Maxfield, Rebecca A wrote:
> Hi there,
> 
> I have a Tomcat installation running a few different web apps 
> (different instances of XTF, if it matters), and each of these has 
> some resources (PDFs, raw XML, etc.) that can be viewed by the
> user in the browser. How can I make sure that the user sees the
> resource with the favicon of the correct site, since there’s
> nowhere for me to put a <link> tag like there is on the actual
> pages of the site?

You can't. Not really. But you might be able to fake it.

> Looking into support forums beforehand, I found solutions for
> giving a resource a favicon by putting the icon in the web apps
> root folder so that it’s over the whole site (not good with more
> than one webapp/site), and for making sites have different icons by
> using the <link> tags, but nothing that solves both of these
> problems.

This is why you can't do what you are asking to be able to do: the
favicon "spec" is the the icon is in the root of the domain, unless
overridden by a <link> element in the HTML document.

> I also tried a solution with htaccess but it didn’t work – not
> sure if I wrote it badly or if that’s not the right way to go.

I have no idea how you might do this with .htaccess.

> This is on Linux; I think the version of Tomcat I’m sandboxing
> this in is version 8, though the production server version is 7.

Have a look at this SO answer:
http://stackoverflow.com/questions/11227661/adding-favicon-through-a-htt
p-header

Here's a way you might be able to fake it:

1. Write a Filter (or you could do this with mod_rewrite I suppose)
2. Hook on the request for /favicon.ico
3. Examine the request headers for the REFERER (yes, it's misspelled)
4. Return the bits you want depending upon the value of that header

This might not work for e.g. PDF files, but it would work for HTML
files that don't specify their own <link> elements. YMMV.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJYHQxbAAoJEBzwKT+lPKRYUD0P/0Pz1xmhSVV/nNUPGBF3qxmj
wWQPsbI+sK5I8X6+Yg19Cr/hjLmflsiENRq7PN7lPZ6S8lxbuCxRWwSlokWDRV8s
7dCaqbs9iPcEhd9Ey0rUwDAhR27H4x75MIA7e4dU0sVIGCsSiMYhw5OD6Td55IcZ
PDfjL5drCI0193wkC+ac5sH56y1iU9KOfaxrzh5woXsQd25rZbPBA8nP5uWmS+Cy
L0dEJ9UnLS3uBd4P4naKIy8Mrxd4OyWr67m03po5AaQwI3NkVLqkdG5fSfg6UN+w
b58aN97cNPsToidIA8sYDOPUKFW1eRroBGLzaBL1JfKAIq/J61WRQ/NpuhugT0IM
eqQ4KAEC1h4zzeAdF+Ak4G9N+AxOg95j7wvLN+c0klnYM5Uzw6ilW07E5tqLqWjM
eOaP8AL2IMfeqg+ANlTIdzFsx3hKXtZchDQ2QGp0epqvW31XefHoLuaK8RH7JtQo
2DekKfJp8ssLun1IshkKYu+SsHH/QTTzhO16ygQc2/vtqJpe4WZ2iuDsfQwbpPEr
NmVmF5WVJIG0ewcTSTz+8sl1NtpcqyMtRYMbikRXGZPXppahYtKyqVViM/SMDqMJ
RB8meG+sFNb3M8NrLiwtbtCFax7rgjM2zbPneCNr8xEPBCF0Rx8XwhuSSiHOEcHY
HfEiCDCsGD+fSvYZrHA7
=rRty
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message