开发者

Configure Tomcat to send web pages compatible to IE 7 or 6

开发者 https://www.devze.com 2022-12-30 02:00 出处:网络
I have got an application that is not compatible to work using IE8 browser. I am looking for a way to to configure Tomcat on which this application run, so the pages could be read by IE8 and treated

I have got an application that is not compatible to work using IE8 browser.

I am looking for a way to to configure Tomcat on which this application run, so the pages could be read by IE8 and treated as if they are IE7 or IE6

By googling so far I found a possible suggestion which say to add to the http response the header: X-UA-Compatible: IE=EmulateIE7

here

that tell IE8 to be like IE7.

The problem is that this way requires adding a filter that should be added on application level. I'd like to know if any of you is familiar with a开发者_StackOverflow社区 more generic way that Tomcat enables to send its http content to be IE7 (or IE6) compatible ?


  1. Download urlrewritefilter-4.0.3.jar from http://tuckey.org/urlrewrite/
  2. Add urlrewritefilter-4.0.3.jar to WEB-INF/lib
  3. Add following code to WEB-INF/web.xml
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
  1. Make a new configuration file for the module. (WEB-INF/urlrewrite.xml)
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN" "http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<urlrewrite>
<rule><condition name="user-agent">.*MSIE.*</condition>
<set type="response-header" name="X-UA-Compatible">IE=EmulateIE7</set>
</rule>
</urlrewrite>


Tomcat is a general purpose webserver and servlet container. It is absolutely browser-agnostic thus, there's no way to configure it in some special way to deal with IEs.

You don't have to add filter really. The bare minimum is to set the response header anywhere in "service" method (or doGet or doPost, whatever application uses):

res.addHeader("X-UA-Compatible", "IE=EmulateIE7 ");

But this is in case when there's a single entry point in the server application. Otherwise filter should do the job in a better way.


See this forum thread that discusses exactly the same situation you are describing. It seems that a filter is the best way to go. As an answer at the above thread suggests, you could use Url Rewrite Filter.

Also, if you are using Apache Web Server to proxy Tomcat, you could easily configure it to add any header to the response.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号