sending multiple response from a servlet

S

spartacus

Hi,

Basically I want to solve a timeout problem, where server closes
connection when it has to wait for a long time to retrieve data from
db. I wanted to send some
blank( or status) value to the client browser so that it stay alive.

Any idea how this can be done? Read some where that, only one reponse
can be sent back from a request. trying out with threads and fails to
submit more than one response.

please give some pointers

-regards.
 
A

Antti S. Brax

Basically I want to solve a timeout problem, where server closes
connection when it has to wait for a long time to retrieve data from
db. I wanted to send some
blank( or status) value to the client browser so that it stay alive.
please give some pointers

Increase server's timeout value or make the DB operation less
complex (possibly by breaking it up into multiple operations).

Solving problems by adding kludgery should be your last resort.
 
A

Andrea Desole

spartacus said:
Any idea how this can be done? Read some where that, only one reponse
can be sent back from a request. trying out with threads and fails to
submit more than one response.

according to the HTTP specs, you can send more than one informational
responses:

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.1

This might work, but I don't know if you can do that from a servlet; I
think there might be a problem after you flush the buffer, because the
response is committed and it doesn't take other changes, which means you
can't send the second one.
But it can be a solution.
Or you can send a new request from the client side, reloading the page
every n seconds.
 
H

Heiner Kücker

Andrea Desole wrote
according to the HTTP specs, you can send more than one informational
responses:

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.1

This might work, but I don't know if you can do that from a servlet; I
think there might be a problem after you flush the buffer, because the
response is committed and it doesn't take other changes, which means you
can't send the second one.
But it can be a solution.
Or you can send a new request from the client side, reloading the page
every n seconds.

To send a new request form your client browser is useful the meta refresh:

<head>
<title>Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="refresh" content="0; URL=http://www.xxx.com/servlet">
</head>


--
Heiner Kuecker
Internet: http://www.heinerkuecker.de http://www.heiner-kuecker.de
JSP WorkFlow PageFlow Page Flow FlowControl Navigation: http://www.control-and-command.de
Java Expression Formula Parser: http://www.heinerkuecker.de/Expression.html
CnC Template Technology http://www.heinerkuecker.de/Expression.html#templ
Domain Specific Languages http://www.heinerkuecker.de/DomainParser.html
 
S

spartacus

Heiner said:
Andrea Desole wrote

To send a new request form your client browser is useful the meta refresh:

<head>
<title>Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="refresh" content="0; URL=http://www.xxx.com/servlet">
</head>


--
Heiner Kuecker
Internet: http://www.heinerkuecker.de http://www.heiner-kuecker.de
JSP WorkFlow PageFlow Page Flow FlowControl Navigation: http://www.control-and-command.de
Java Expression Formula Parser: http://www.heinerkuecker.de/Expression.html
CnC Template Technology http://www.heinerkuecker.de/Expression.html#templ
Domain Specific Languages
http://www.heinerkuecker.de/DomainParser.html


Thank you everyone for their valuable inputs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top