您的位置:首页 > Web前端 > JavaScript

jsp内置对象详解

2015-03-30 14:13 323 查看
/* * jsp存在9大内置对象,其中的除了exception外八大对象要么是Servlet的参数,要么是Servlet的局部变量,所以在页面中,通过表达式语言可以直接访问。 */1.request封装了请求的所有的参数,系统默认提供如下方法作为向外借口,是HttpServletRequest的实例Object getAttribute(String name);//返回指定的属性值String getCharacterEncoding(); // 返回字符编码方式int getContentLength();
// 返回请求体的长度(以字节数)String getContentType(); // 得到请求体的MIME类型ServletInputStream getInputStream(); // 得到请求体中一行的二进制流String getParameter(String name); // 返回name指定参数的参数值Enumeration getParameterNames(); //返回可用参数名的枚举String[] getParameterValues(String name);// 返回包含参数name的所有值的数组String
getProtocol();// 返回请求用的协议类型及版本号String getScheme();// 返回请求用的计划名,如:http.https及ftp等String getServerName();// 返回接受请求的服务器主机名int getServerPort();// 返回服务器接受此请求所用的端口号BufferedReader getReader();// 返回解码过了的请求体String getRemoteAddr();// 返回发送此请求的客户端IP地址String getRemoteHost()
;//返回发送此请求的客户端主机名void setAttribute(Stringkey,Objectobj);// 设置属性的属性值String getRealPath(Stringpath);// 返回一虚拟路径的真实路径 2.response 服务返回给客户端的参数,是HttpServletResponse的实例String getCharacterEncoding();// 返回响应用的是何种字符编码ServletOutputStream getOutputStream();// 返回响应的一个二进制输出流PrintWriter
getWriter() ;//返回可以向客户端输出字符的一个对象void setContentLength(int len);// 设置响应头长度void setContentType(String type);// 设置响应的MIME类型sendRedirect(String location);// 重新定向客户端的请求 3.session 客户端与服务器的回话,从客户端打开网页开始,到页面关闭位置。是httpSession的实例long getCreateTime();//返回session创建的时间String
getId(); //获取session的Id号,每个session都有一个唯一的id,用于识别不同的客户端连接long getLastAccessTime();//返回session的最后一次访问时间int getMaxInactiveInterval();//返回两次访问的最大时长String [] getValueNames();//获取所有可用的属性值void invalidate();//取消sessionboolean isNew();//判断客户端是否加入了新建的sessionvoid removeValue(String
name);//删除属性4.out jspWriter的实例void clear();//清空缓冲区的内容void clearBuffer();//清空当前缓冲区void flush();//清空流int getBufferSize();//获取缓冲区的大小int getRemaining();//获取缓冲区的剩余大小boolean isAutoFlush();//缓冲区满时是否自动清空void close();//关闭流5.pageclass getClass();int hashCode();boolean
equals(Object obj);void copy(Object obj);Object clone();String toString();void notify();void notifyAll();void wait(int time);void wait();void enterMonitor();//加锁void exitMonitor();//解锁6.application //全局的属性,所有用户的共享数据是ServletContext的实例Object getAttribute(String
name);// 返回给定名的属性值Enumeration getAttributeNames();// 返回所有可用属性名的枚举void setAttribute(String name,Object obj);// 设定属性的属性值void removeAttribute(String name);// 删除一属性及其属性值String getServerInfo() ;//返回JSP(SERVLET)引擎名及版本号String getRealPath(String path);// 返回一虚拟路径的真实路径ServletContext
getContext(String uripath);// 返回指定WebApplication的application对象int getMajorVersion();// 返回服务器支持的ServletAPI的最大版本号int getMinorVersion();// 返回服务器支持的ServletAPI的最大版本号String getMimeType(String file);// 返回指定文件的MIME类型URL getResource(String path);// 返回指定资源(文件及目录)的URL路径InputStream
getResourceAsStream(String path) ;//返回指定资源的输入流RequestDispatcher getRequestDispatcher(String uripath);// 返回指定资源的RequestDispatcher对象Servlet getServlet(String name) ;//返回指定名的ServletEnumeration getServlets();// 返回所有Servlet的枚举Enumeration getServletNames() ;//返回所有Servlet名的枚举void
log(String msg) ;//把指定消息写入Servlet的日志文件void log(Exception exception,String msg) ;//把指定异常的栈轨迹及错误消息写入Servlet的日志文件void log(String msg,Throwable throwable);// 把栈轨迹及给出的Throwable异常的说明信息写入Servlet的日志文件7.exceptionString getMessage();void printStackStrace();8.pageContext;//页面环境JspWriter
getOut();// 返回当前客户端响应被使用的JspWriter流(out)HttpSession getSession();// 返回当前页中的HttpSession对象(session)Object getPage();// 返回当前页的Object对象(page)ServletRequest getRequest();// 返回当前页的ServletRequest对象(request)ServletResponse getResponse();// 返回当前页的ServletResponse对象(response)Exception
getException() 返回当前页的Exception对象(exception)ServletConfig getServletConfig();// 返回当前页的ServletConfig对象(config)ServletContext getServletContext();// 返回当前页的ServletContext对象(application)void setAttribute(Stringna e,Object attribute) ;//设置属性及属性值void setAttribute(Stringname,Objectobj,intscope);//
在指定范围内设置属性及属性值Object getAttribute(Stringname);// 取属性的值Object getAttribute(String name,int scope);// 在指定范围内取属性的值Object findAttribute(Stringname);// 寻找一属性,返回起属性值或NULLvoid removeAttribute(Stringname);// 删除某属性void removeAttribute(String name,int scope);// 在指定范围删除某属性int
getAttributeScope(Stringname);// 返回某属性的作用范围Enumeration getAttributeNamesInScope(int scope);// 返回指定范围内可用的属性名枚举void release();// 释放pageContext所占用的资源void forward(String relativeUrlPath);// 使当前页面重导到另一页面void include(String relativeUrlPath);// 在当前位置包含另一文件9.config//初始化配置;如连接数据库信息,web.xml中配置的信息
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jsp 内置对象