avoid duplication
separated out servlet handling logic from the main thing.

... in preparation for the remoting support