title: Java / JSP Send TCP packet and wait for response
body: <p>I'm trying to send a TCP packet. It sends correctly to the server but sender is not getting response (server is sending response back correctly). Client doesn't even process code afeter sending the packet...</p>
  
  <pre><code> Socket socket = new Socket (ip, port);
  
   PrintWriter mOut = new PrintWriter(socket.getOutputStream(), true);  
   mOut.print("DSPSYSSTS");
  
   //Everything works fine until here
  
   BufferedReader mIn = new BufferedReader (new InputStreamReader (socket.getInputStream ()));
   String fromClient = mIn.readLine();
   out.println ("Client Message: " + fromClient);
  
   mOut.close();
   mIn.close ();      
   socket.close ();
  </code></pre>
  
  <p>The JSP doesn't print the input and it remains loading forever. What's wrong?</p>
  
  <p>Returning String of <code>systemRequest.request</code> in below code</p>
  
  <pre><code>ReadSpoolFile readSplf = new ReadSpoolFile(splfArray.get(0));
  String splfContent = readSplf.read();
  
  GetSystemStatus getSysSts = new GetSystemStatus();
  String systemStatus = getSysSts.get(splfContent);
  return systemStatus + "\r\n";
  </code></pre>
  
  <p>Server side Response:</p>
  
  <pre><code>String response = systemRequests.request(message, SystemRequests.SILENT_OFF);
  
  ChannelBuffer mCbResponse;
  
  if(response != null){
  mCbResponse = ChannelBuffers.copiedBuffer(response.getBytes());
  mChannel.write(mCbResponse);    //&lt;------Write response
  </code></pre>