473,289 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

Sending HttpServletRespone before reading entire HttpServletRequest

Hi all,

I will do an experiment on this soon, but if anyone knows off the top
of their head...

Let's say you have a servlet that processes a POST request. A HTTP
client sends a POST request to this servlet and attaches a relatively
long body to the request, say 4MB. The type of the body doesn't
matter, let's say it's just text/plain.

The servlet will have its doPost() operation invoked, and it will be
able to read the (4MB of) data from the HttpServletRequest object. It
will take a relatively long time to read all the data.

Now, can the servlet send back a HttpServletResponse (could be really
short, just a couple of lines in the body) to the client before the
servlet has finished reading all of the 4MB request? Let's say that
after reading 2MB of the body, the servlet decides that it doesn't
like the request. Can it send back a premature response? Is there any
way for the client to know that the server is no longer reading the
request and that the client should look for a response now?

Thanks in advance for any thoughts on the matter!

Desmond
Jul 17 '05 #1
1 2675
"des" == des riv <de*****@hotmail.com> writes:

des> Now, can the servlet send back a HttpServletResponse (could
des> be really short, just a couple of lines in the body) to the
des> client before the servlet has finished reading all of the 4MB
des> request?

Yes.

des> Let's say that after reading 2MB of the body, the servlet
des> decides that it doesn't like the request. Can it send back a
des> premature response?

Yes.

des> Is there any way for the client to know that the server is no
des> longer reading the request and that the client should look
des> for a response now?

The client can start reading for a response at any time, but it really
should write the entire request out, particularly if it is using HTTP
1.1 with connection keep alive. With 1.0 you can get away with a half
close if you figure out that the response has already arrived (for
which you would have to poll the socket to see if it is there).

I strongly suggest you write out the entire request from the client
until you feel you understand exactly how HTTP 1.0 and HTTP 1.1
requests use Content-Length and Connection fields. The servlet engine
will discard the request if you don't read it.

Cheers!
Shyamal
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: sookean | last post by:
Hi, I have a jsp with some list box. And when user selects an option in the list box, I would then generate a url to direct the user to the correct page. The url is of the form:...
0
by: Christine Zhou | last post by:
Hi, We have a customized HttpServletRequest object, when we run the application on webshpere 4.0.7,got a ClassCastException on this object, but was Ok on WAS4.0.1, Anyone know why, is this...
9
by: Sandy | last post by:
can mfc application, send text data to opened notepad file in desktop?(live transfer of data) . can anybody help
5
by: Vishal | last post by:
Hello, I already asked this question in the ASP.NET forums, but no help came. So I am hoping that somebody can help me out. This is really very URGENT me. For my e-commerce application, I...
2
by: Sean | last post by:
Hi guys, I have a question. I am trying to write a simple echo program. The objective is to read in a file in chuncks into the buffer and transfer the buffer over the socket. We repeat this until...
2
by: =?Utf-8?B?Q2FwdGFpbiBEYXZlIQ==?= | last post by:
I wrote some code to send an email with two alternate views: 1) html 2) plain text All the html enabled email clients accept the html just fine and disregard the plain text version. However,...
2
by: mfsiddiq | last post by:
Hi Everyone I need help regarding how to get the handle for httpServlet while using webService.Since we are using webservice,i am not able to get handle of httpServletRequest and...
1
by: creative1 | last post by:
When I test the application I get follwowing error: could not connect to smtp host: connection timeout error can someone please check if I have rigth settings? Where I am wrong here Is IP and...
1
by: =?utf-8?q?C=C3=A9dric_Lucantis?= | last post by:
Le Tuesday 24 June 2008 08:59:40 Piyush Anonymous, vous avez écrit : One way is to transmit the code as a string and compile it on server-side with the 'compile' builtin function. Another is...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.