空指针问题
/*
* @(#)FTag.java
*
* Copyright 2004 Java Frame Application Corporation.
* All Rights Reserved.
*
*/
package jfa.lib.app.web.tag;
import.....
/**
* <p>标签基类</p>
* <p>
* 统一JSP和WAP使用的标签<br>
* 1. 定义标签开始和结束的逻辑操作<br>
* 2. 一些环境变量的存储
* </p>
*
* @author AlexCN
* @version 1.00 - 2003/06/12
*/
public class FTag extends FComponent implements Tag {
// 页面的环境对象
private PageContext m_oPageContext = null;
// 父节点对象
private Tag m_oParent = null;
// WEB应用程序的环境对象
private FWebContext m_oWebContext = null;
/**
* <p>创建标签对象的实例</p>
* <p>create date:2004/07/16</p>
*
*/
public FTag() {
}
/**
* <p>设置页面环境对象</p>
* <p>create date:2004/07/16</p>
*
* @param oPageContext 页面环境对象
*/
public void setPageContext(PageContext oPageContext) {
m_oPageContext = oPageContext;
// 获得和设置WEB应用程序的环境对象
m_oWebContext = (FWebContext) oPageContext.getRequest().getAttribute(
IWebGlobals.INSTANCE_WEB_CONTEXT);
m_oWebContext.setResponseWriter(oPageContext.getOut());这行空指针
}
/**
* <p>获得页面环境对象</p>
* <p>create date:2004/07/16</p>
*
* @retrun 页面环境对象
*/
public PageContext getPageContext() {
return m_oPageContext;
}
/**
* <p>设置父标签对象</p>
* <p>create date:2004/07/16</p>
*
* @param oParent 父标签对象
*/
public void setParent(Tag oParent) {
m_oParent = oParent;
}
/**
* <p>获得父标签对象</p>
* <p>create date:2004/07/16</p>
*
* @retrun 父标签对象
*/
public Tag getParent() {
return m_oParent;
}
/**
* <p>设置WEB应用程序的环境对象</p>
* <p>create date:2004/07/16</p>
*
* @param oParent 父标签对象
* @return TRUE:成功<BR>FALSE:失败
*/
public boolean setWebContext(FWebContext oContext) {
m_oWebContext = oContext;
return true;
}
/**
* <p>获得WEB应用程序的环境对象</p>
* <p>create date:2004/07/16</p>
*
* @retrun WEB应用程序的环境对象
*/
public FWebContext getWebContext() {
return m_oWebContext;
}
/**
* <p>获得类型为指定类的父标签对象</p>
* <p>create date:2004/07/16</p>
*
* @retrun 标签对象
*/
public FTag getOwnerByClassName(Class oClass) {
if (oClass != null) {
FTag oTag = (FTag) getParent();
while (oTag != null) {
if (FClass.isInherit(oTag, oClass)) {
return oTag;
}
oTag = (FTag) oTag.getParent();
}
}
return null;
}
/**
* <p>开始标签的逻辑</p>
* <p>create date:2004/05/19</p>
*
* @param oContext 环境对象
* @return 逻辑执行后的状态
* @exception FException 逻辑例外
*/
public int doStartTag(FWebContext oContext)
throws FException {
return (oContext != null) ? EVAL_BODY_INCLUDE : SKIP_BODY;
}
/**
* <p>开始标签的逻辑</p>
* <p>create date:2004/05/19</p>
*
* @return 逻辑执行后的状态
* @exception JspException JSP例外
*/
public int doStartTag()
throws JspException {
try {
return doStartTag(getWebContext());
} catch (Exception oException) {
FLogger.error(this, "FTag.doStartTag", oException);
throw new JspException(oException);
}
}
/**
* <p>结束标签的逻辑</p>
* <p>create date:2004/05/19</p>
*
* @param oContext 环境对象
* @return 逻辑执行后的状态
* @exception FException 逻辑例外
*/
public int doEndTag(FWebContext oContext)
throws FException {
return (oContext != null) ? EVAL_PAGE : SKIP_PAGE;
}
/**
* <p>结束标签的逻辑</p>
* <p>create date:2004/05/19</p>
*
* @return 逻辑执行后的状态
* @exception FException 逻辑例外
*/
public int doEndTag()
throws JspException {
try {
int nResult = doEndTag(getWebContext());
release();
return nResult;
} catch (Exception oException) {
FLogger.error(this, "FTag.doEndTag", oException);
throw new JspException(oException);
}
}
/**
* <p>释放标签所使用的资源</p>
* <p>create date:2004/07/16</p>
*
*/
public void release() {
m_oPageContext = null;
m_oParent = null;
m_oWebContext = null;
}
}