对象 类型 说明 作用域
request javax.servlet.http.HttpServletRequest 得到客户端信息 request
response javax.servlet.http.HttpServletResponse 响应 page
pageContext javax.servlet.jsp.PageConext JSP页面容器 page
session javax.servlet.http.HttpSession 产生的session数据 session
application javax.servlet.ServletContext 同用getServletConext() application
out javax.servlet.jsp.jspWriter 数据流的标准输出 page
config javax.servlet.ServletConfig 表示此JSP的ServletConfig page
page java.lang.Object 同java中的this page
exception java.lang.Throwable 异常处理 page
request/session/application:setAttribute(属性名,属性值);getAttribute(属性名)
四大类:
一、与input/output有关的:
request:
1.请求参数:getParameter(String name)/getParameterNames()/getParameterValues(String name)
2.取得请求标头的方法:getHeader(String name)/getHeaderNames()/getHeaders(String name)/getIntHeader(String name)/getDateHeader(String name)/getCookies()
3.其它:getMethod()/getProtocol()/getQueryString()/getRequestURL()/getRequestDispatcher(String path)/getRemoteAddr()/getRemoteHost()/getRemoteUser()/getSession()
response:
1.设置标头的方法:addCookie(Cookie cookie)/addDateHeader(name,date)/addHeader(name,value)/addIntHeader(name,value)/setDateHeader(name,date)/setHeader(name,value)/setIntHeader(name,value)
2.设置响应代号的方法:setError(int sc,String msg)/sendRedirect(String location)/setStatus(int sc)
3.用来使用URL重写的方法:encodeRedirectURL(String url)/endcodeURL(String url)
自动刷新:response.setHeader("Refresh","10,URL=http://")
<META HTTP-EQUIV="Refresh" CONTENT="10,URL=http://">
跳转:<jsp:forward page="">/response.sendRedirect();
Cookie:Cookie co=new Cookie("name","value");response.addCookie(co)
方法:setMaxAge(秒)/request.getCookie()/getName()/getValue()
out:
对象方法:clearBuffer()/close()/getBufferSize()/getRemaning()/isAutoFlush()
二、JSP执行时,提供有关Context的:
session:
常用方法:getCreationTime()/getId()/getLastAccessedTime()/getMaxInactiveInterval()/invalidate()/isNew()/setMaxInactiveInterval(int interval)
application:
取得服务器端的信息:getContext(URL);getMajorVersion()/getMimeType(URL)/getRealPath(URL)/getServletInfo()
常用方法:getAttribute(String key)/getAttributeNames()/removeAttribute(String key)/setAttribute(String key,Object value)
pageContext:
方法:getException()/getOut()/getPage()/getRequest()/getResponse()/getServletConfig()/getServletContext()/getSession()
取得属性方法:getAttribute()/getAttributeNamesInScope(scope)/getAttributeScope(name)/removeAttribute(name)/removeAttribute(name,scope)/setAttribute(name,value,scope)/findAttribue(name)
scope:PAGE_SCOPE;REQUEST_SCOPE;SESSION_SCOPE;APPLICATION_SCOPE
三、与Servlet有关的:
page:
config:getServletContext()/getServletName()/getInitParameter(String name)/getInitParameterNames()
四、与Error有关的内置对象:exception
JSP内置对象
最新推荐文章于 2023-10-25 09:58:50 发布