Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Accessing ColdFusion CFC from a jsp page

Explorer ,
Jan 15, 2010 Jan 15, 2010

I have created functions in cfc, the problem now is that the front pages are jsp pages. How can I pass query data from the cfc to the JSP pages? what will the calls from the jsp look like?

516
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jan 15, 2010 Jan 15, 2010

If you set the functions in the CFC to have an access type of "remote", you can call them as any other web service.

O.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 18, 2010 Jan 18, 2010
LATEST

You might also need to specify that the return-format is to be "JSON."

Consider what happens when, say, an AJAX-based application makes a request.  It submits an HTTP "POST" to a CFC, with the variables (possibly JSON-encoded if they are complex data-types).  One of the parameters is "method," which ColdFusion interprets as a specification of the method-name to be called.

ColdFusion looks for the <cffunction> and that its "access=remote."  If so, it issues an ordinary function-call.  The function returns a result, as usual, which ColdFusion encodes and sends back as the response text.

You can use exactly the same techniques from your JSP-side code, and "it ought to be very easy to do."  But remember:  it will be asynchronous.  You will issue your request to the ColdFusion server, and after some unpredictable amount of time has passed the response will come back.  JSP knows how to do such calls, and to handle the results thereof.  "It happens all the time."  If the strategy you're coming up with isn't "easy," then you're probably barking up the wrong tree and need to look closer.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources