servlet构造response,以及获取RequestDispatcher对象
来源:互联网 发布:淘宝网夏季新款女装 编辑:程序博客网 时间:2024/05/26 19:19
Constructing Responses
A response contains data passed between a server and the client. All responses implement the
ServletResponse interface. This interface defines methods that allow you to
■ Retrieve an output stream to use to send data to the client. To send character data, use the
PrintWriter returned by the response’s getWriter method. To send binary data in a
Multipurpose InternetMail Extensions (MIME) body response, use the
ServletOutputStream returned by getOutputStream. To mix binary and text data, as in a
multipart response, use a ServletOutputStream and manage the character sections
manually.
■ Indicate the content type (for example, text/html) being returned by the response with the
setContentType(String) method. This method must be called before the response is
committed. A registry of content type names is kept by the Internet AssignedNumbers
Authority (IANA) at http://www.iana.org/assignments/media-types/.
■ Indicate whether to buffer output with the setBufferSize(int) method. By default, any
content written to the output stream is immediately sent to the client. Buffering allows
content to be written before anything is sent back to the client, thus providing the servlet
Writing ServiceMethods
Chapter 10 • Java Servlet Technology 203
with more time to set appropriate status codes and headers or forward to another web
resource. The method must be called before any content is written or before the response is
committed.
■ Set localization information, such as locale and character encoding.
To invoke a resource available on the server that is running a web component, you must first
obtain a RequestDispatcher object by using the getRequestDispatcher("URL") method. You
can get a RequestDispatcher object from either a request or the web context; however, the two
methods have slightly different behavior. The method takes the path to the requested resource
as an argument. A request can take a relative path (that is, one that does not begin with a /), but
the web context requires an absolute path. If the resource is not available or if the server has not
implemented a RequestDispatcher object for that type of resource, getRequestDispatcher
will return null. Your servlet should be prepared to deal with this condition.
- servlet构造response,以及获取RequestDispatcher对象
- servlet跳转(RequestDispatcher)的获取
- Servlet中获得转发对象(RequestDispatcher)
- Servlet response对象
- Servlet Response对象
- Servlet之Response对象
- Servlet Response对象
- Servlet中的response对象
- Servlet (三 Response 对象)
- response.sendRedirect 与 RequestDispatcher
- Servlet获取Request和Response
- Servlet的Response对象解析
- Servlet JSP 之间的跳转 response.sendRedirect()和RequestDispatcher().forward的比较
- javax.servlet.RequestDispatcher翻译
- Servlet ---- RequestDispatcher请求转发
- javax.servlet.RequestDispatcher:
- Servlet------RequestDispatcher请求转发
- Response.sendRedirect()与RequestDispatcher.forward()
- scroll view原理
- 反转一个字节 和 判断32位整数二进制中1的个数 的算法(ZZ)
- 反转一个字节 和 判断32位整数二进制中1的个数 的算法(ZZ)
- 上网八个常用cmd命令你掌握了几个?
- asp.net basepage
- servlet构造response,以及获取RequestDispatcher对象
- 转载——C语言中return的一些总结
- DataGrid动态添加列
- 二叉树三种遍历的非递归算法(背诵版)
- 本地域名解析地址
- ★★☆ Visual Studio 2008 每日小窍门 【持续发布中~】 Tips:103
- 同一页面中的取值赋值
- 在windows xp系统下配置eclipse集成hadoop开发
- SQL