You can implement this with both servlets and even JSP. But this is not the kind of work that a servlet (not to mention JSP) is usually supposed to handle.
Try to consider having all this stuff hidden in some service component.
At a minimum, keep all the logic that handles communication over the socket in one class that is used by the servlet.
One step further with the decoupling would be to define a "DataService" interface that would expose the getData() / sendCommand() /... methods and make the SocketConnector class implement that interface. The servlet will only make use of the interface (without knowing anything about the actual implementation, so that you will be able to change your business tier without touching the servlet): For this you can make use of some dependency injection container (Spring,
EJB 3, ...) or simply have a factory method returning the actual implementation.
The above servlet in this case will look like this:
As you can see, your servlet doesn't even import the SocketConnector anymore, so you can switch the actual data provider without any modification required in your servlet. Just have the DataServiceFactory return some other implementation.
With a framework like Spring (and maybe making use of Spring MVC), you don't need the factory and you can simply "inject" your service into the controller.