title: Servlet response write vs print? Which is better?
body: <p>I am having a string which needs to be sent as response from a servlet &amp; I am having two approaches to send response back from it.</p>
  
  <p>First is using PrintWriter.</p>
  
  <blockquote>
    <p>response.getWriter().print(responseString);</p>
  </blockquote>
  
  <p>Second is using OutputStream.</p>
  
  <pre><code> byte[] byteResponse = responseString.getBytes(Charset.forName("UTF-8"));
   response.getOutputStream().write(byteResponse);
  </code></pre>
  
  <p>I want to know which is better and efficient way of sending response?</p>
  
  <p>Please suggest.</p>