09-04
27
如何在action中或servlet中得到pageContext
作者:Java伴侣 日期:2009-04-27
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);
以下是飛思科技<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);
评论: 0 | 引用: 0 | 查看次数: 497
发表评论