Mikolaj Rydzewski wrote:
Clement Low wrote:
I would like to set a custom header to all of the pages that my Tomcat serve
:


*<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />*


What this does is basically telling IE 8 to display the particular page as
if it were in IE 7.

I do not want to add this header to every page that I have. What can I do to
tell Tomcat to achieve this?
The better way is to implement a servlet filter and declare it in application's web.xml descriptor.

Hi.

I believe that, in theory, the <meta http-equiv="xxxx" content="yyyy" ... > tag in the html document, should have the same effect as if the server, in the HTTP headers of the response, had sent a header like
xxxx: yyyy
before sending the actual content of the html page.

In other words, in your case, adding to the HTTP response a HTTP header like :

X-UA-Compatible: IE=EmulateIE7

should do the trick.

I have never tried the above, and I am not sure about it, but if it turns out to be true, then there should be more than one possibility to achieve what you want, in the order easiest first :

1) find an existing Tomcat add-on module (a filter) which is capable of adding a HTTP header to the responses of Tomcat.
I suggest to have a look here :
http://tuckey.org/urlrewrite/
and further here :
http://urlrewritefilter.googlecode.com/svn/trunk/src/doc/manual/3.1/index.html
Look at the <set> element, with type="response-header".

That module (urlrewrite) is a servlet filter, and can do a wide variety of things, and adding an outgoing HTTP header is among what it can do.

2) If that does not work for you, then you could write your own servlet filter, to do the same (adding a HTTP header to the response). It is not a very complicated servlet filter to write, and there are probably some examples and tutorials floating around.

3) If that in the end does not work (meaning I amwrong, and the trick of adding this as a HTTP header does not work at all), then you would need a filter which scan and modifies each html response page, to insert this <meta ..> tag. I believe that this is a lot less efficient than merely adding a HTTP header, which is the reason why I put this solution only in third place. But basically, that is what most Content Management and templating systems systems do, so it cannot be so bad.
In that case, again you have a choice :

3a) find an existing servlet filter which does that.

3b) write your own servlet filter to do it.
It also does not sound extremely complicated, because you merely want to insert the same string into any outgoing html document.
But I am sure that you will find some complications on the way.

I believe that if the only thing you want to do is to add the meta tag, to *all* outgoing pages, 3b) may then anyway be your best bet, efficiency-wise, because it is likely that any solution you will find for 3a) will probably do a lot more, and thus be a lot heavier. On the other hand, maybe it would be useful in the end to be able to do a lot more, and maybe efficiency is not very important in this case.




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to