Websphere和Tomcat下使用PageContex有什么区别?

来源:百度知道 编辑:UC知道 时间:2024/06/28 07:30:25
公司的开发环境用的是Tomcat,而测试环境用的则是Websphere6。
在开发过程中,某个Jsp文件使用了PageContex指定其属性:
default_value="<%=(String)((Model) pageContext.getAttribute("list")).getName()%>",调试没有问题,可是放到测试服务器上确无法解析,请问各位高手这是什么原因,应该怎么解决?

PageContext在websphere和Tomcat的不同实现
关键字: PageContext

今天碰到一个奇怪的问题,明明本地上好好的页面扔到服务器上就是通不过,搞了半天,才发现是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 valu