title: How to set content type = "application/json" in mule.?
body: <p>I have a HTML file which consists of a Form and it takes certain parameters from the User and when the URL is hit, a Mule service (written in Java) is called and it returns a JSON string. Now how can I set <code>Content-type</code> = <code>application/json</code> in either Mule or Java, so that browser know that it is getting a JSON?</p>
  
  <p>My Mule config file is :</p>
  
  <pre><code>&lt;custom-transformer name="HttpParams" class="org.mule.transport.http.transformers.HttpRequestBodyToParamMap" /&gt;
  &lt;message-properties-transformer name="HttpResponse"&gt;
      &lt;add-message-property key="Content-Type" value="application/json" /&gt;
      &lt;add-message-property key="http.status" value="303" /&gt;
  &lt;/message-properties-transformer&gt;
  
  &lt;flow name="jcars"&gt;
      &lt;http:inbound-endpoint address="http://localhost:11221/jcars" transformer-refs="HttpParams" responseTransformer-refs="HttpResponse"&gt;
          &lt;not-filter&gt;
             &lt;wildcard-filter pattern="/favicon.ico"/&gt;
          &lt;/not-filter&gt;
      &lt;/http:inbound-endpoint&gt;
  
      &lt;component class="defaults.basicapp.jcars"/&gt;
  &lt;/flow&gt;
  </code></pre>
  
  <p>And my Java class is (Jcars) :</p>
  
  <pre><code>public String onEvent(Object obj){
  
       String json = "{{"id":0,"model":"suzuki","make":"2002","ps":true,"price":101.2,"bhp":12.6},{"id":0,"model":"suzuki","make":"2003","ps":true,"price":101.2,"bhp":12.6},{"id":0,"model":"suzuki","make":"2004","ps":true,"price":101.2,"bhp":12.6},{"id":0,"model":"suzuki","make":"2005","ps":true,"price":101.2,"bhp":12.6},{"id":0,"model":"suzuki","make":"2006","ps":true,"price":101.2,"bhp":12.6}}";
  
       return json;
  }
  </code></pre>
  
  <p>The browser is displaying the string as it is. It does not know that the content type is <code>application/json</code>. What should I do?</p>