1、 Action或Servlet中获取PageContext
PageContext pageContext = JspFactory.getDefaultFactory()
.getPageContext(this.servlet, request, response, null,
true, 8192, true);
如果是servlet,把this.servlet改为this
2、 在servlet中如何声明application
JSP是在Servlet基础上发展而来的,
其application对象在Servlet中是ServletContext的实例对象,
可以在你写的Servlet中通过this.getServletContext();方法来获取一个ServletContext实例对象.
比如:
this.getServletContext().setAttribute("users",userList); //this可换做PageContext
3、 在servlet中ServletContext就是application对象
在 jsp编译出来的 java文件里就会看到
是如何定义的 application
ServletContext application = null;
application = pageContext.getServletContext();