PageContext在websphere和Tomcat的不同实现

    今天碰到一个奇怪的问题,明明本地上好好的页面扔到服务器上就是通不过,搞了半天,才发现是was 与tomcat 的差异造成的。

    跟踪到出错的位置,JSP代码如下:

java 代码
  1. String parentBSID = (String)request.getAttribute("parentBSID");    
  2. pageContext.setAttribute("parentBSID", parentBSID);   

在百度上搜索websphere pageContextImpl.setAttribute null,居然一无所获;google 搜出来的几个页面慢得跟蜗牛一样,没办法只能靠自己。反编译tomcat与websphere应用服务器上对应的PageContextImpl类,结果如下:

tomcat 的standard.jar包中对PageContextImpl的实现是:

java 代码
  1. mPage = Collections.synchronizedMap(new HashMap());  

而was 的webcontainer.jar中对PageContextImpl的实现是:

java 代码
  1. attributes = new Hashtable(16);  

tomcat和websphere对pageContext的实现最关键的差别就是前者使用了HashMap,后者使用了Hashtable,Java API Document 对Hashtable.put(Object key,Object value)有明确说明:“Maps the specified key to the specified value in this hashtable. Neither the key nor the value can be null.

问题解决,可能很多人已经发现了这个差异,但我搜索不到,所以写在这给有需要的人作个参考吧。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值