when I to exported it and put it on the web it doesn't workIf you exported your server into JavaScript mode, it wouldn't work, as processing.net.* libraries only work in Java mode.
If you exported your server as Applet from processing, then it was exported as unsigned applet, which means that you cannot start server and listen to the ports. Here's some more detail:
The solution would be to run your "server" sketch on some computer (for example your laptop) all the time.
Or you canrun your sketch on remote Linux headless server (let's say Amazon EC2)