Java Servlet - setContentLength()
来源:互联网 发布:c 编程思想 pdf 编辑:程序博客网 时间:2024/05/01 14:02
Posts:27
Registered: 23/5/06 setContentLength()
Sep 29, 2006 2:59 AM
I want to know what does setContentLength() method does.
My concern is that if a set content length to some value and then send less data to the stream , and afterwards when i read back from httpResponse object , will there be any issues ...like null characters, or junk characters etc.
More over if we write to stream without setting content length will it work?
Plz help
brian@cubik.ca
Posts:458
Registered: 1/18/04 Re: setContentLength()
Sep 29, 2006 3:16 PM (reply 1 of 1)
It causes the Content-Length header to be set with the value you provide it. You don't really need it for sending back type 'text/html', but if you're sending binary files, it's the only way that the progress indicator in your browser will work. Sending the wrong Content-Length header will probably result in browser-dependant weirdness. Perhaps the file will be truncated. The progress indicator may hit 100% and still be downloading. If you don't know how long the Content is, then don't send the header.
Brian
Registered: 23/5/06 setContentLength()
Sep 29, 2006 2:59 AM
I want to know what does setContentLength() method does.
My concern is that if a set content length to some value and then send less data to the stream , and afterwards when i read back from httpResponse object , will there be any issues ...like null characters, or junk characters etc.
More over if we write to stream without setting content length will it work?
Plz help
brian@cubik.ca
Posts:458
Registered: 1/18/04 Re: setContentLength()
Sep 29, 2006 3:16 PM (reply 1 of 1)
It causes the Content-Length header to be set with the value you provide it. You don't really need it for sending back type 'text/html', but if you're sending binary files, it's the only way that the progress indicator in your browser will work. Sending the wrong Content-Length header will probably result in browser-dependant weirdness. Perhaps the file will be truncated. The progress indicator may hit 100% and still be downloading. If you don't know how long the Content is, then don't send the header.
Brian
- Java Servlet - setContentLength()
- java servlet
- Java Servlet
- Java Servlet
- java servlet
- java---servlet
- java servlet
- Java Servlet
- Java Servlet
- java servlet
- java Servlet
- Java Servlet
- java servlet
- java servlet
- java servlet
- Java-Servlet
- Java Servlet
- Java Servlet
- 读研为了什么,为将来指明方向的一篇文章
- 如何使Ubuntu下的Opera浏览器可以使用Flash插件
- 插花问题的“动态规划法”算法
- 程序员如何买股票
- 常用的正则表达式的收集
- Java Servlet - setContentLength()
- Java的一些有用的类
- 利用操作系统提供的API编写防火墙
- 我们的未来:一个浏览器足矣!
- commons-fileupload 文件上传问题
- BDS2006的工程,路径不能含中文?
- j2ee学习流程(转载)
- 我的故事
- 《完美Excel》(第1期)发布