Re: Java Autopostback?

Vittorix <vittorix@xxxxxxxxx> wrote:
I'm writing a web server in Java for html and servlets.

In general, I'd recommend reusing one of the MANY choices already available.
Tomcat or Jetty are the ones I'd start with, but lists plenty to choose from.

Writing one for your own education is fine, of course, but I'd recommend start
small, maybe static files and a subset of the servlet spec.

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).

Umm, you're mixing up client and server behavior. If you're going to write an
http server, do NOT use a browser as your primary test harness. Use a test
client that gives you control over content, and validates the return rather
than rendering it.

I'd probably use the Jakarta Commons HttpClient package, run from JUnit.

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

1) Fire up a command-line post utility and see what's really going on. Or
install LiveHTTPHeaders in firefox. It's very likely that you're assuming a
format that doesn't actually match what's transmitted. And it's equally
likely that the bug isn't in this snippet of code, but somewhere around it.

2) Using blocking buffered IO in a server like this is asking for trouble.
Even if you get it working correctly, you're setting yourself up for pain when
you encounter a browser that behaves incorrectly. You should read blocks of
data, and parse them as needed.
Mark Rafn dagon@xxxxxxxxx <>

Relevant Pages

  • Re: Got TCP/IP connection, but no file sharing!?
    ... No where can I find that having the Computer Browser Service ... and the server announces itself on the networking using the special ... and why doesn't a workgroup environment work the same ... server) generally acts as the master browser. ...
  • Re: =?ISO-8859-1?Q?Can=92t_see_a_compute?= =?ISO-8859-1?Q?r_in_the_network?=
    ... Find Computer Browser ... Find Server ... Find Workstation ... CONFIG and Browser and Sharedaccess are RUNNING. ...
  • Re: After setting up the network
    ... Find Computer Browser ... Find Server ... PsService v2.20 - Service information and configuration utility ... CPSServ Comprehensive Networking Services V1.10 - PERRINS2 ...
  • Re: BROWSTAT: ...Could not connect to registry, error = 53 (New question)
    ... I have found that I can resolve this message situation by mapping a drive share to the Master Browser machine. ... Now name resolution uses Server Message Blocks or SMBs. ... use the same SMB transport, or they will have no connection (causing, among ... NetBT setting, is not consistently effective. ...
  • Re: After setting up the network
    ... Master browser name is: PERRINS2 ... C:\Documents and Settings\Leon Perrins>net config server ... PsService v2.20 - Service information and configuration utility ...