- 浏览: 233525 次
文章分类
- 全部博客 (160)
- java语言基础 (67)
- jsp基础 (2)
- eclipse使用 (2)
- java源码解读 (6)
- 计算机基础 (3)
- eclipse插件 (0)
- 网络基础 (8)
- 算法 (2)
- linux (0)
- 英语 (0)
- C语言 (4)
- JavaScript (17)
- 数学 (0)
- struts2 (2)
- 自然哲学 (0)
- Servlet (1)
- HttpServer (2)
- ext (1)
- 个人 (1)
- dojo (27)
- spring (2)
- hibernate (4)
- css (3)
- 多线程 (0)
- chrome插件开发 (0)
- svn (0)
- thrift (2)
- phonegap (1)
- java线程 (1)
- 不是很熟悉的css属性 (0)
- 数据库性能调优 (0)
- 项目管理 (1)
- ios (0)
- 软件工程 (0)
- db2 (0)
- 词汇管理 (0)
- zhenyan (0)
- 计划 (0)
- android (0)
- ssss (0)
- 是的 (0)
- dsada (0)
- 泛点是 (0)
- fds (0)
- cxzc (0)
- 权限 (0)
- dfsfds (0)
- http://www.cnblogs.com/kingboy2008/p/5261771.html (0)
- sss (0)
- ddd (0)
- fdsfdsf (0)
- sso (0)
- nginx (0)
- 分布式数据一致性 (0)
- mysql (0)
- ios永久存储 (0)
- js匿名函数 (0)
- 打印机qqq (0)
最新评论
/** * Defines an object to provide client request information to a servlet. The * servlet container creates a <code>ServletRequest</code> object and passes * it as an argument to the servlet's <code>service</code> method. * * <p>A <code>ServletRequest</code> object provides data including * parameter name and values, attributes, and an input stream. * Interfaces that extend <code>ServletRequest</code> can provide * additional protocol-specific data (for example, HTTP data is * provided by {@link javax.servlet.http.HttpServletRequest}. * * @author Various * * @see javax.servlet.http.HttpServletRequest * */ public interface ServletRequest { /** * * Returns the value of the named attribute as an <code>Object</code>, * or <code>null</code> if no attribute of the given name exists. * * <p> Attributes can be set two ways. The servlet container may set * attributes to make available custom information about a request. * For example, for requests made using HTTPS, the attribute * <code>javax.servlet.request.X509Certificate</code> can be used to * retrieve information on the certificate of the client. Attributes * can also be set programatically using * {@link ServletRequest#setAttribute}. This allows information to be * embedded into a request before a {@link RequestDispatcher} call. * * <p>Attribute names should follow the same conventions as package * names. This specification reserves names matching <code>java.*</code>, * <code>javax.*</code>, and <code>sun.*</code>. * * @param name a <code>String</code> specifying the name of * the attribute * * @return an <code>Object</code> containing the value * of the attribute, or <code>null</code> if * the attribute does not exist * */ public Object getAttribute(String name); /** * Returns an <code>Enumeration</code> containing the * names of the attributes available to this request. * This method returns an empty <code>Enumeration</code> * if the request has no attributes available to it. * * * @return an <code>Enumeration</code> of strings * containing the names * of the request's attributes * */ public Enumeration getAttributeNames(); /** * Returns the name of the character encoding used in the body of this * request. This method returns <code>null</code> if the request * does not specify a character encoding * * * @return a <code>String</code> containing the name of * the character encoding, or <code>null</code> * if the request does not specify a character encoding * */ public String getCharacterEncoding(); /** * Overrides the name of the character encoding used in the body of this * request. This method must be called prior to reading request parameters * or reading input using getReader(). Otherwise, it has no effect. * * @param env <code>String</code> containing the name of * the character encoding. * @throws java.io.UnsupportedEncodingException if this * ServletRequest is still in a state where a * character encoding may be set, but the specified * encoding is invalid */ public void setCharacterEncoding(String env) throws java.io.UnsupportedEncodingException; /** * Returns the length, in bytes, of the request body * and made available by the input stream, or -1 if the * length is not known. For HTTP servlets, same as the value * of the CGI variable CONTENT_LENGTH. * * @return an integer containing the length of the * request body or -1 if the length is not known * */ public int getContentLength(); /** * Returns the MIME type of the body of the request, or * <code>null</code> if the type is not known. For HTTP servlets, * same as the value of the CGI variable CONTENT_TYPE. * * @return a <code>String</code> containing the name * of the MIME type of * the request, or null if the type is not known * */ public String getContentType(); /** * Retrieves the body of the request as binary data using * a {@link ServletInputStream}. Either this method or * {@link #getReader} may be called to read the body, not both. * * @return a {@link ServletInputStream} object containing * the body of the request * * @exception IllegalStateException if the {@link #getReader} method * has already been called for this request * * @exception IOException if an input or output exception occurred * */ public ServletInputStream getInputStream() throws IOException; /** * Returns the value of a request parameter as a <code>String</code>, * or <code>null</code> if the parameter does not exist. Request parameters * are extra information sent with the request. For HTTP servlets, * parameters are contained in the query string or posted form data. * * <p>You should only use this method when you are sure the * parameter has only one value. If the parameter might have * more than one value, use {@link #getParameterValues}. * * <p>If you use this method with a multivalued * parameter, the value returned is equal to the first value * in the array returned by <code>getParameterValues</code>. * * <p>If the parameter data was sent in the request body, such as occurs * with an HTTP POST request, then reading the body directly via {@link * #getInputStream} or {@link #getReader} can interfere * with the execution of this method. * * @param name a <code>String</code> specifying the * name of the parameter * * @return a <code>String</code> representing the * single value of the parameter * * @see #getParameterValues * */ public String getParameter(String name); /** * * Returns an <code>Enumeration</code> of <code>String</code> * objects containing the names of the parameters contained * in this request. If the request has * no parameters, the method returns an * empty <code>Enumeration</code>. * * @return an <code>Enumeration</code> of <code>String</code> * objects, each <code>String</code> containing * the name of a request parameter; or an * empty <code>Enumeration</code> if the * request has no parameters * */ public Enumeration getParameterNames(); /** * Returns an array of <code>String</code> objects containing * all of the values the given request parameter has, or * <code>null</code> if the parameter does not exist. * * <p>If the parameter has a single value, the array has a length * of 1. * * @param name a <code>String</code> containing the name of * the parameter whose value is requested * * @return an array of <code>String</code> objects * containing the parameter's values * * @see #getParameter * */ public String[] getParameterValues(String name); /** Returns a java.util.Map of the parameters of this request. * Request parameters * are extra information sent with the request. For HTTP servlets, * parameters are contained in the query string or posted form data. * * @return an immutable java.util.Map containing parameter names as * keys and parameter values as map values. The keys in the parameter * map are of type String. The values in the parameter map are of type * String array. * */ public Map getParameterMap(); /** * Returns the name and version of the protocol the request uses * in the form <i>protocol/majorVersion.minorVersion</i>, for * example, HTTP/1.1. For HTTP servlets, the value * returned is the same as the value of the CGI variable * <code>SERVER_PROTOCOL</code>. * * @return a <code>String</code> containing the protocol * name and version number * */ public String getProtocol(); /** * Returns the name of the scheme used to make this request, * for example, * <code>http</code>, <code>https</code>, or <code>ftp</code>. * Different schemes have different rules for constructing URLs, * as noted in RFC 1738. * * @return a <code>String</code> containing the name * of the scheme used to make this request * */ public String getScheme(); /** * Returns the host name of the server to which the request was sent. * It is the value of the part before ":" in the <code>Host</code> * header value, if any, or the resolved server name, or the server IP address. * * @return a <code>String</code> containing the name * of the server */ public String getServerName(); /** * Returns the port number to which the request was sent. * It is the value of the part after ":" in the <code>Host</code> * header value, if any, or the server port where the client connection * was accepted on. * * @return an integer specifying the port number * */ public int getServerPort(); /** * Retrieves the body of the request as character data using * a <code>BufferedReader</code>. The reader translates the character * data according to the character encoding used on the body. * Either this method or {@link #getInputStream} may be called to read the * body, not both. * * * @return a <code>BufferedReader</code> * containing the body of the request * * @exception UnsupportedEncodingException if the character set encoding * used is not supported and the * text cannot be decoded * * @exception IllegalStateException if {@link #getInputStream} method * has been called on this request * * @exception IOException if an input or output exception occurred * * @see #getInputStream * */ public BufferedReader getReader() throws IOException; /** * Returns the Internet Protocol (IP) address of the client * or last proxy that sent the request. * For HTTP servlets, same as the value of the * CGI variable <code>REMOTE_ADDR</code>. * * @return a <code>String</code> containing the * IP address of the client that sent the request * */ public String getRemoteAddr(); /** * Returns the fully qualified name of the client * or the last proxy that sent the request. * If the engine cannot or chooses not to resolve the hostname * (to improve performance), this method returns the dotted-string form of * the IP address. For HTTP servlets, same as the value of the CGI variable * <code>REMOTE_HOST</code>. * * @return a <code>String</code> containing the fully * qualified name of the client * */ public String getRemoteHost(); /** * * Stores an attribute in this request. * Attributes are reset between requests. This method is most * often used in conjunction with {@link RequestDispatcher}. * * <p>Attribute names should follow the same conventions as * package names. Names beginning with <code>java.*</code>, * <code>javax.*</code>, and <code>com.sun.*</code>, are * reserved for use by Sun Microsystems. *<br> If the object passed in is null, the effect is the same as * calling {@link #removeAttribute}. * <br> It is warned that when the request is dispatched from the * servlet resides in a different web application by * <code>RequestDispatcher</code>, the object set by this method * may not be correctly retrieved in the caller servlet. * * * @param name a <code>String</code> specifying * the name of the attribute * * @param o the <code>Object</code> to be stored * */ public void setAttribute(String name, Object o); /** * * Removes an attribute from this request. This method is not * generally needed as attributes only persist as long as the request * is being handled. * * <p>Attribute names should follow the same conventions as * package names. Names beginning with <code>java.*</code>, * <code>javax.*</code>, and <code>com.sun.*</code>, are * reserved for use by Sun Microsystems. * * * @param name a <code>String</code> specifying * the name of the attribute to remove * */ public void removeAttribute(String name); /** * * Returns the preferred <code>Locale</code> that the client will * accept content in, based on the Accept-Language header. * If the client request doesn't provide an Accept-Language header, * this method returns the default locale for the server. * * * @return the preferred <code>Locale</code> for the client * */ public Locale getLocale(); /** * * Returns an <code>Enumeration</code> of <code>Locale</code> objects * indicating, in decreasing order starting with the preferred locale, the * locales that are acceptable to the client based on the Accept-Language * header. * If the client request doesn't provide an Accept-Language header, * this method returns an <code>Enumeration</code> containing one * <code>Locale</code>, the default locale for the server. * * * @return an <code>Enumeration</code> of preferred * <code>Locale</code> objects for the client * */ public Enumeration getLocales(); /** * * Returns a boolean indicating whether this request was made using a * secure channel, such as HTTPS. * * * @return a boolean indicating if the request was made using a * secure channel * */ public boolean isSecure(); /** * * Returns a {@link RequestDispatcher} object that acts as a wrapper for * the resource located at the given path. * A <code>RequestDispatcher</code> object can be used to forward * a request to the resource or to include the resource in a response. * The resource can be dynamic or static. * * <p>The pathname specified may be relative, although it cannot extend * outside the current servlet context. If the path begins with * a "/" it is interpreted as relative to the current context root. * This method returns <code>null</code> if the servlet container * cannot return a <code>RequestDispatcher</code>. * * <p>The difference between this method and {@link * ServletContext#getRequestDispatcher} is that this method can take a * relative path. * * @param path a <code>String</code> specifying the pathname * to the resource. If it is relative, it must be * relative against the current servlet. * * @return a <code>RequestDispatcher</code> object * that acts as a wrapper for the resource * at the specified path, or <code>null</code> * if the servlet container cannot return a * <code>RequestDispatcher</code> * * @see RequestDispatcher * @see ServletContext#getRequestDispatcher * */ public RequestDispatcher getRequestDispatcher(String path); /** * * @deprecated As of Version 2.1 of the Java Servlet API, * use {@link ServletContext#getRealPath} instead. * */ public String getRealPath(String path); /** * Returns the Internet Protocol (IP) source port of the client * or last proxy that sent the request. * * @return an integer specifying the port number * * @since 2.4 */ public int getRemotePort(); /** * Returns the host name of the Internet Protocol (IP) interface on * which the request was received. * * @return a <code>String</code> containing the host * name of the IP on which the request was received. * * @since 2.4 */ public String getLocalName(); /** * Returns the Internet Protocol (IP) address of the interface on * which the request was received. * * @return a <code>String</code> containing the * IP address on which the request was received. * * @since 2.4 * */ public String getLocalAddr(); /** * Returns the Internet Protocol (IP) port number of the interface * on which the request was received. * * @return an integer specifying the port number * * @since 2.4 */ public int getLocalPort(); }
发表评论
-
mysql并发
2013-01-08 13:38 0/** * 测试msql JDBC连接并发安全性 ... -
java注解2
2013-01-06 22:02 1021由前一篇的代码,运行代码如下:public clas ... -
java注解1
2013-01-06 21:56 948本文演示java注解的使用 1. getDe ... -
Java集合框架分析
2012-08-29 21:28 01. Java集合整体框架 下面的两张图说明 ... -
AbstractList
2012-08-29 20:48 980public abstract class Abstra ... -
Set
2012-08-28 11:17 680public interface Set<E> e ... -
List源码
2012-08-28 11:15 1009public interface List<E&g ... -
Collection源码
2012-08-28 11:13 946public interface Collection< ... -
java集合框架
2012-08-28 10:39 0java的集合框架中,主要有3类常用的集合。 -
web的debug
2012-03-29 10:48 0hh -
文件读取
2012-03-10 19:32 0public class Util { publ ... -
HTML元素的访问
2011-11-30 09:31 0有3忠方法可以访问html中的元素。 -
Schema数据类型
2011-11-26 16:34 0Schema不仅内置了丰富的数据类型,而且还允许开发者 ... -
初学XML3
2011-11-26 10:08 0编写了XML Schema语义约束之后,必须将其导入目 ... -
初学XML2
2011-11-26 09:22 820<?xml version="1.0& ... -
初学XML
2011-11-26 08:50 889<?xml version="1.0&q ... -
JavaScript字符串
2011-11-19 21:29 920JavaScript有三种基本数据类型,字符串,数字以 ... -
项目管理
2011-11-05 22:39 0项目管理开始于项目计划阶段,贯穿于整个系统开发生命周期 ... -
项目可行性分析
2011-11-05 21:23 0项目可行性包括三个方面:技术可行性,经济可行性,组织 ... -
系统开发生命周期
2011-11-05 21:16 0系统开发生命周期有四个4个基本阶段: 计划- ...
相关推荐
本篇文章将深入探讨`ServletRequest`接口,以及如何使用它来处理来自客户端的请求。 ### ServletRequest接口 `ServletRequest`接口代表了客户端发送到服务器的一个请求,它是`javax.servlet`包下的核心接口。这个...
`ServletRequest`接口是Java Servlet API中用于处理客户端请求的主要接口,它为开发者提供了获取请求数据的各种方法。`HttpServletRequest`是`ServletRequest`的一个实现类,专门针对HTTP协议,提供了更具体的操作...
本文将深入解析ServletRequest类的相关源代码,帮助你理解其内部工作机制。 首先,ServletRequest接口位于javax.servlet包下,它是所有请求对象(如HttpServletRequest)的基础。它定义了一系列方法,如...
提供了ServletRequest过滤程序,重新构造对象内容,并有效规避request.getParameter()、request.getInputStream()冲突的问题,同时提供了对跨站脚本攻击XSS和SQL注入的过滤程序。
超全面javaweb教程28天第9天_7_Servlet相关类之ServletRequest和Servletresponse对象
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; // ...
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; ...
The method setAttribute String Object in the type ServletRequest is not applicable for the arguments String int
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) { HttpServletRequest decoratedRequest = new HttpServletRequestWrapper((HttpServletRequest) request); // 在...
doFilter(ServletRequest, ServletResponse, FilterChain) - Method in interface javax.servlet.Filter The doFilter method of the Filter is called by the container each time a request/response pair is ...
Servlet被初始化之后,它已经可以处理来自客户端的请求,每一个来自客户端的请求都被描述成一个ServletRequest对象,Servlet的响应被描述成一个ServletResponse对象。 当客户端发出请求时,Servlet引擎传递给Servlet...
- **签名**:`public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException;` - **功能**:此方法用于将请求从当前 Servlet 发送给另一个资源。这通常发生在...
JavaWeb核心之Servlet。...2)service(ServletRequest request,ServletResponse response) 何时执行:每次请求都会执行 ServletRequest :代表请求 认为ServletRequest 内部封装的是 http请求的信息
Servlet可以通过`ServletRequest`和`ServletContext`接口提供的方法来获取服务器的相关信息: - `ServletRequest.getServerName()`:返回发送请求的服务器的主机名。 - `ServletRequest.getServerPort()`:返回...
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest httpServletRequest = ...
Tomcat解析这些信息,将其封装到ServletRequest对象中。 2. **ServletRequest对象创建**: Tomcat根据解析出的请求信息,创建一个ServletRequest对象。此对象包含了所有客户端请求的相关信息,例如请求头中的...
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpSession session = ((HttpServletRequest) request).getSession(); /...
- 监听`ServletContext`、`HttpSession`和`ServletRequest`对象的生命周期事件以及这些对象属性的添加、替换和移除。 - 提供对应用、会话和请求对象交互的更多控制。 - 实现对事件的集中监控和响应。 #### 二、...
监听器基于Java的事件驱动模型,通过实现特定的接口,可以在ServletContext、HttpSession和ServletRequest等对象的生命周期事件(如创建、销毁)或者属性变化时执行自定义逻辑。 1. **Servlet监听器的基本原理** -...
1. `forward(ServletRequest request, ServletResponse response)`:将当前请求和响应对象转发给指定的资源。 2. `include(ServletRequest request, ServletResponse response)`:在当前请求处理过程中插入指定资源...