title: respond to http request with json object in portlet
body: <p>I am a beginner in liferay portlet development and I am developing a portlet that receives a http get request, processes some information and than it has to return a json object. My problem is that my portlet sends a whole html page instead of just the json object. 
  This is my code:</p>
  
  <pre><code>HttpServletResponse servletResponse = PortalUtil.getHttpServletResponse((renderResponse));
  
              servletResponse.setHeader("Content-type", "application/json");
              servletResponse.setCharacterEncoding("application/json");
              PrintWriter out = servletResponse.getWriter();
              out.write(EntityUtils.toString(responseEntity));
  
  
              out.flush();
              out.close();
  </code></pre>
  
  <p>I execute this in the doView() method I know that this is not the best practice, but I am not concerned with that at the moment. Can someone explain to me how to return just the json object I read something about serveResponse, but I couldn't figure out how to invoke it. </p>