`

WAS 6.0.2.9 部署应用使用过滤器问题解决办法

阅读更多

支撑环境: IBM WebSphere Application 6.0.2.9 集群环境

 

需要实现功能:

在用户访问以下链接“t20090526_79507.jsp”时由Filter 转向到同名的“t20090526_79507.html”文件,前提“t20090526_79507.jsp”该文件不存在

过滤之前的链接1:

http://localhost:9080/govweb/zwxx/taya/200905/t20090526_79507.jsp?channelid=1014&channelclass=F

 

这个访问链接1后是经过过滤器转换后并转向的链接:

http://localhost:9080/govweb/zwxx/taya/200905/t20090526_79507.html?channelid=1014&channelclass=F

 

Java过滤器代码:

StringBuffer url = hreq.getRequestURL();

    if(url.substring(url.length()-3, url.length()).equals("jsp")){

       url.replace(url.length()-3, url.length(), "html");

       url.append("?").append(hreq.getQueryString());

       redirect(hreq, hres, url.toString());

       return;

    }

 

 

问题现象:本人在Tomcat和JBoss和WebLogic下测试没有问题,但部署到WAS上之后就会出现

404错误,说文件不存在。

结果终于在网上找到相关资料,原来是WAS的一个Bug,

PK31377: SERVLET FILTER IS NOT CALLED FOR URL RESOURCES WHEN THEY ARE NOT FOUND.

原文是这样写的:

Problem summary 
****************************************************************
* USERS AFFECTED: IBM WebSphere Application Server version 6   *
*                 users of servlet filters.                    *
****************************************************************
* PROBLEM DESCRIPTION: The WebContainer is not calling servlet *
*                      filters when a resource is not found.   *
****************************************************************
* RECOMMENDATION:                                              *
****************************************************************
During the processing of a request for a particular resource
the WebContainer does not call any custom servlet filters. It
is not uncommon for a developer to write a custom servlet
filter that will modify the request to look in a different
location if a particular resource was not found.
Also, custom servlet filters were are not called prior to
iterating through the welcome file list in search of a resource.
Problem conclusion 
The WebContainer code was modified to call the custom servlet
filters prior to looking for welcome files.  Also, if the
WebContainer cannot find a resource, it will now call the
filters before throwing a FileNotFoundException in case the
filters modify the path to the resource.

The following WebContainer custom property must be set to
'true' for this new behaviour to be enabled:
'com.ibm.ws.webcontainer.invokeFiltersCompatibility'

The fix for this APAR is currently targeted for inclusion in
fixpacks 6.0.2.21 and 6.1.0.9.

Please refer to the Recommended Updates page for delivery
information:
http://www.ibm.com/support/docview.wss?rs=180&uid=swg27004980

 

 

结果把先将 WAS升级到 6.0.2.33以后版本,再在WAS服务器容器中添加以下属性后

com.ibm.ws.webcontainer.invokeFiltersCompatibility=true

测试成功!

 

 

 

 

 

这个问题困惑了本人近一个月时间,希望对有相同问题的朋友有所帮助

 

 

  • mytest.rar (9.5 KB)
  • 描述: 过滤器问题测试程序
  • 下载次数: 3
1
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics