Hi everybody,
I'm writing a web server in Java for html and servlets.
when the server receives a GET request, it works fine.
problem: when I use POST, the server program stops and the submit button has
to be clicked another time or the page has to be manually refreshed (after
that it works fine).
so, the program waits for the client to send a new signal/request.
The problem is caused by a in.readLine() statement:
if(method.equals("GET") && URI.contains("?"))
paraLine = URI.substring(URI.indexOf("?")+1, URI.length());
else if(method.equals("POST"))
paraLine = in.readLine(); // in the POST request, the parameters are
in the http request body
how to avoid that?

Signature
ciao
Vittorix
derek - 26 Jan 2008 00:08 GMT
> Hi everybody,
> I'm writing a web server in Java for html and servlets.
[quoted text clipped - 11 lines]
> in the http request body
> how to avoid that?
My suggestion would be to get some software to watch the data that is getting sent to your pogram.
I like Fidler from microsoft.
Then when you see what data is being sent you can get a better idea of what you need to do.
.
=====================================================
THIS IS MY SIGNATURE. There are many like it, but this one is mine.
Vittorix - 26 Jan 2008 01:01 GMT
> My suggestion would be to get some software to watch the data that is
> getting sent to your pogram. I like Fidler from microsoft.
> Then when you see what data is being sent you can get a better idea
> of what you need to do.
thanks, but didn't help.
Fiddler doesn't catch traffic on localhost.
I know I can workaround with the server name, but even checking what is sent
doesn't solve the problem.
it still waits. there must be a specific issue and solution.

Signature
ciao
Vittorix
Naveen Kumar - 26 Jan 2008 09:28 GMT
> > My suggestion would be to get some software to watch the data that is
> > getting sent to your pogram. I like Fidler from microsoft.
[quoted text clipped - 10 lines]
> ciao
> Vittorix
in.readLine() makes the program wait for line feed ('\n') or a
carriage return ('\r').. guess that might cause a problem.. y dont u
try using read() ??
Cheers
Naveen Kumar
Vittorix - 28 Jan 2008 19:12 GMT
> in.readLine() makes the program wait for line feed ('\n') or a
> carriage return ('\r').. guess that might cause a problem.. y dont u
> try using read() ??
yes, this is the idea. and I did thys way, thanks:
else if(method.equals("POST"))
{ // POST method
int ch;
int len = Integer.parseInt((String)
headers.get("Content-Length")); // POST request Content-Length header
paraLine = "";
for(int i=1; i<=len; i++)
{
ch = in.read();
paraLine += (char) ch; // in the POST request,
the parameters are in the http request body
}
}

Signature
ciao
Vittorix