c***a 发帖数: 69 | 1 【 以下文字转载自 SanFrancisco 讨论区,原文如下 】
发信人: cilla (想飞的猪~戒肉), 信区: SanFrancisco
标 题: Re: 觉得自己很笨
发信站: The unknown SPACE (Wed Aug 6 21:03:19 2003) WWW-POST
java问题
client open 一个HttpURLConnection 以后getInputStream,
trigger了servlet对HttpServletRequest处理,可是servlet端运行的时间长一些,没有
等到往outputstream里写东西,client的getInputStream就返回了,开始读,自然啥也读
不到。我觉得是HttpConnection timeout了,可是不知道怎么set这个timeout的值。我用
的websphere application developer 5.0
再网上search
很久了,发现别人问的问题都是说如果servlet迟迟不writeout,client会hang,我的behav
ior怎么不一样呢?而且HttpURLC | w********c 发帖数: 2632 | 2 HttpUrlConnection doesn't allow u to manipulate the timeout value. Maybe u
have to either use Socket or Apache HttpClient.
有
读
用
很久了,发现别人问的问题都是说如果servlet迟迟不writeout,client会hang,我的behav
timeout的值的,除非改用socket
【在 c***a 的大作中提到】 : 【 以下文字转载自 SanFrancisco 讨论区,原文如下 】 : 发信人: cilla (想飞的猪~戒肉), 信区: SanFrancisco : 标 题: Re: 觉得自己很笨 : 发信站: The unknown SPACE (Wed Aug 6 21:03:19 2003) WWW-POST : java问题 : client open 一个HttpURLConnection 以后getInputStream, : trigger了servlet对HttpServletRequest处理,可是servlet端运行的时间长一些,没有 : 等到往outputstream里写东西,client的getInputStream就返回了,开始读,自然啥也读 : 不到。我觉得是HttpConnection timeout了,可是不知道怎么set这个timeout的值。我用 : 的websphere application developer 5.0
| v**o 发帖数: 64 | 3 这个timeout好像是在http server中设的,参考一下apache的httpd.conf文件说明吧
有
读
用
很久了,发现别人问的问题都是说如果servlet迟迟不writeout,client会hang,我的behav
timeout的值的,除非改用socket
【在 c***a 的大作中提到】 : 【 以下文字转载自 SanFrancisco 讨论区,原文如下 】 : 发信人: cilla (想飞的猪~戒肉), 信区: SanFrancisco : 标 题: Re: 觉得自己很笨 : 发信站: The unknown SPACE (Wed Aug 6 21:03:19 2003) WWW-POST : java问题 : client open 一个HttpURLConnection 以后getInputStream, : trigger了servlet对HttpServletRequest处理,可是servlet端运行的时间长一些,没有 : 等到往outputstream里写东西,client的getInputStream就返回了,开始读,自然啥也读 : 不到。我觉得是HttpConnection timeout了,可是不知道怎么set这个timeout的值。我用 : 的websphere application developer 5.0
| e***g 发帖数: 158 | 4 well, keep reading, as long as the input stream is there.
【在 c***a 的大作中提到】 : 【 以下文字转载自 SanFrancisco 讨论区,原文如下 】 : 发信人: cilla (想飞的猪~戒肉), 信区: SanFrancisco : 标 题: Re: 觉得自己很笨 : 发信站: The unknown SPACE (Wed Aug 6 21:03:19 2003) WWW-POST : java问题 : client open 一个HttpURLConnection 以后getInputStream, : trigger了servlet对HttpServletRequest处理,可是servlet端运行的时间长一些,没有 : 等到往outputstream里写东西,client的getInputStream就返回了,开始读,自然啥也读 : 不到。我觉得是HttpConnection timeout了,可是不知道怎么set这个timeout的值。我用 : 的websphere application developer 5.0
| m******t 发帖数: 2416 | 5
The javadoc of InputStream.read() clearly states:
"This method blocks until input data is available, the end of
the stream is detected, or an exception is thrown."
Since you are not getting any exception,
unless the server closes the connection(in which case you'd get
a return value of -1), a read() call should be blocking until there is
some data available.
I would consider using Apache HttpClient.
【在 c***a 的大作中提到】 : 【 以下文字转载自 SanFrancisco 讨论区,原文如下 】 : 发信人: cilla (想飞的猪~戒肉), 信区: SanFrancisco : 标 题: Re: 觉得自己很笨 : 发信站: The unknown SPACE (Wed Aug 6 21:03:19 2003) WWW-POST : java问题 : client open 一个HttpURLConnection 以后getInputStream, : trigger了servlet对HttpServletRequest处理,可是servlet端运行的时间长一些,没有 : 等到往outputstream里写东西,client的getInputStream就返回了,开始读,自然啥也读 : 不到。我觉得是HttpConnection timeout了,可是不知道怎么set这个timeout的值。我用 : 的websphere application developer 5.0
| w******n 发帖数: 692 | 6 Why not use InputStream().available() to check the number of bytes that
can be read?
【在 m******t 的大作中提到】 : : The javadoc of InputStream.read() clearly states: : "This method blocks until input data is available, the end of : the stream is detected, or an exception is thrown." : Since you are not getting any exception, : unless the server closes the connection(in which case you'd get : a return value of -1), a read() call should be blocking until there is : some data available. : I would consider using Apache HttpClient.
|
|