📄 page_context.xtp
字号:
<title css='default.css'>PageContext</title><objsummary/><section title='PageContext'><defun title='attribute'><sum>This object contains page scope variables.</sum> In particular,beans declared with the jsp:useBean page scope are stored in thepageContext attribute.<example><example><% pageContext.attribute.a = 1; pageContext.attribute.b = 2; for (var name in pageContext.attribute) out.writeln(name, ": ", pageContext.attribute[name]); %></example><results>a: 1b: 2</results></example></defun><defun title='out'><sum>Returns the JspWriter for this response.</sum> This is the sameas the JSP 'out' implicit variable. JspWriter has the same properties andmethods as output <a href='stream.html'>streams</a>.<example><example><% pageContext.out.writeln("Hello, world");%></example><results>Hello, world</results></example></defun><defun title='session'><sum>Returns the page's <a href='session.html'>session</a>.</sum><example><example>Welcome back. You've visited<%= pageContext.session.value++ %> times</example></example></defun><defun title='servletContext'><sum>Returns the page's <a href='application.html'>application</a>object.</sum> Along with application variables, the applicationobject lets scripts dynamically include files and forward results.<example><example>You are visistor<%= pageContext.servletContext.attribute++ %></example></example></defun><defun title='servlet'><sum>Returns the page's generated servlet.</sum> <note>This is notthe JSP engine's servlet, but the servlet generated for the particularJSP page.</note><example><example><%@ page info='Special Servlet' %><%= pageContext.servlet.servletInfo %gt;</example><results>Special Servlet</results></example></defun><defun title='servletRequest'><sum>Returns the page's <a href='request.html'>request</a>object.</sum> The request object contains information from the HTTPrequest, such as form data and allows forwarding pages to pass alongattributes.<example><example><% var req = pageContext.servletRequest for (var key in req.form) out.writeln(key, ": ", req.form[key]);%></example><results>name: George Washingtonhonesty: mythical</results></example></defun><defun title='servletResponse'><sum>Returns the page's <a href='response.html'>response</a>object.</sum> The response object lets application set responseheaders and status codes. In general, JSP applications will write tothe 'out' object instead of using the response object directly.<example><% var res = pageContext.servletResponse res.header["Expires"] = new Date().toString()%></example></defun><defun title='exception'><sum>For <a href='jsp-directives.html#errorpage'>error pages</a>,returns the thrown exception.</sum><example><% response.setStatus(500); out.writeln("Exception: ", pageContext.exception)%></example></defun><defun name='include' title='include(href)'><sum>Includes the dynamic contents of the page at <var/href/>.</sum><var/href/> is relative to the current page and its root is theapplication root.<p/><code/include/> is the proper way to include JSP generated contents inthe current page.</defun><defun name='forward' title='forward(href)'><sum>Includes the dynamic contents of the page at <var/href/>.</sum><var/href/> is relative to the current page and its root is theapplication root.<p/><code/forward/> cannot be called after data has returned to thebrowser. Because of JSP's 8k <ahref='jsp-directives.html#buffer'>buffer</a>, most applications canignore this limitation.</defun></section>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -