Redian新闻
>
[转载] Re: 觉得自己很笨
avatar
[转载] Re: 觉得自己很笨# Java - 爪哇娇娃
c*a
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
avatar
w*c
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

avatar
v*o
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

avatar
e*g
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

avatar
m*t
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

avatar
w*n
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.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。