title: How can I send HTTP Status Code and a Response messages to the client in ColdFusion?
body: <p>I am implementing the Single Sign On functionality. I have an ColdFusion application which takes input parameters from Java application (POST request). What I need to do is return status codes and a description to indicate whether the user has access and the failed reason if the user does not have access to my CF application.
  Something like below:
  <a href="https://i.stack.imgur.com/ACX6p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ACX6p.png" alt="enter image description here"></a></p>
  
  <p>I have created a cfc and provided this as an API to allow Java users to pass in their UserName, CustomerID to my CF application. 
  Do I need to write the return response logic in the same file? Like a function which  "throw" error code (cfthrow).</p>
  
  <p>Or may be I can use "cfheader"....something like this:</p>
  
  <pre><code>&lt;cfif form.CustomerId EQ queryname.CustID&gt;
  &lt;CFHEADER 
      STATUSCODE="200"
      STATUSTEXT="Success"&gt;
  
  &lt;cfelse&gt;
   &lt;CFHEADER 
      STATUSCODE="400"
      STATUSTEXT="Insufficient Input"&gt;
  &lt;/cfif&gt;
  </code></pre>
  
  <p>Can anyone please help me here?</p>