<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>pageContext的使用</title> </head> <body> <%pageContext.setAttribute("pageContextParam","pagecontext"); request.setAttribute("requestParam","request"); session.setAttribute("sessionparam","session"); application.setAttribute("applicationParam","application"); %> pageContextParam:<%=pageContext.getAttribute("pageContextParam",pageContext.PAGE_SCOPE) %><br> requestParam:<%=pageContext.getAttribute("requestParam",pageContext.REQUEST_SCOPE) %><br> sessionParam:<%=pageContext.getAttribute("sessionParam",pageContext.SESSION_SCOPE) %><br> applicationParam:<%=pageContext.getAttribute("applicationParam",pageContext.APPLICATION_SCOPE) %>
</body> |
</html>
图 1 使用pageContext内置对象获取内置对象设置的属性 |