09-04
27

如何在action中或servlet中得到pageContext

PageContext是一個抽象類﹐怎么能實例化呢?pageContext是它的隐含物件是什么意思?

以下是飛思科技<jsp 應用開發詳解第二版>中例子
public class HelloTag_Interface implements javax.servlet.jsp,tagext.Tag
{
private PageContext pageContext;
。。。。

public int doEndTag() throws javax.servlet.jsp.JspTagException
{
try{

pageContext.getOut.write("hello,world!"你好世界﹗);
}
...
}
}

PageContext pageContext = JspFactory.getDefaultFactory()
      .getPageContext(this.servlet, request, response, null,
        true, 8192, true);
如果是servlet,把this.servlet改为this

或:

JspFactory _jspxFactory = null;
        PageContext pageContext = null;
        _jspxFactory = JspFactory.getDefaultFactory();
        pageContext = _jspxFactory.getPageContext(this,req,resp,"",true,8192,true);
            
        ServletConfig sconfig=this.getServletConfig();


JspFactory fac=JspFactory.getDefaultFactory();
PageContext pageContext=fac.getPageContext(this, request,response, null, false, JspWriter.DEFAULT_BUFFER, true);


文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: pageContext
相关日志:
评论: 0 | 引用: 0 | 查看次数: 454
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 开启 | [img]标签 关闭