I created a servlet that takes a request, figures it out, does some processing, and at the very end of that processing, it sends a response.. Pretty basic stuff.
I test this using HTTP Client and sometimes, a weird thing happens..
I send the request from the client, and the response received (too quickly) is "200 Ok", but it has no content! I re-send the same request immediately afterwards, and the response is what I expected.
I tried this also with jQuery AJAX and the same thing is happening, more, often that not, especially if it is the first request to the servlet.
Sometimes, the bad response is even repeated for a few requests, before it sends out the correct response.
I'm using Eclipse with Tomcat.. Should I do something with the servlet's configuration?
PS: when I get the correct response, the bad response is never sent again.
ADDED:::
Reproducing the problem again and again, I can see that the servlet sort-of "sleeps"? So a GET to the servlet first has response headers: "200 OK", some others about the time, and a Content-Length: 0. Sending the SAME request again has the proper response and content. JSP pages also sometimes have to be refreshed after being reloaded to reload the content, or else they come up blank.. For eg. If I go to the log-out page (from a link in index.jsp), it shows up blank, till I refresh it. Sometimes, external styles/scripts in a page only come up after a refresh. Very strange.. It seems that the servlet lags behind in providing resources..
Can anyone point me to some good resources about how servlets, sessions and JSP pages work?