{"id":349,"date":"2003-04-10T13:56:04","date_gmt":"2003-04-10T17:56:04","guid":{"rendered":"http:\/\/wordpress.cephas.net\/?p=349"},"modified":"2003-04-10T13:56:04","modified_gmt":"2003-04-10T17:56:04","slug":"cfmx-httpservletrequesthttpservletresponse","status":"publish","type":"post","link":"https:\/\/cephas.net\/blog\/2003\/04\/10\/cfmx-httpservletrequesthttpservletresponse\/","title":{"rendered":"CFMX &amp; HttpServletRequest\/HttpServletResponse"},"content":{"rendered":"<p>I&#8217;m doing some research for an article I&#8217;m writing for Macromedia Devnet (hopefully to be published in May or June).  I won&#8217;t go into the details of the article, but part of it deals (<a href=\"http:\/\/dictionary.reference.com\/search?q=tangentially\">tangentially<\/a>) with CFMX and Java integration.  Specifically, I&#8217;m using CFMX to call a relatively simple Java API that consists of a couple methods, ie:<\/p>\n<p>doSomething(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, long someObject) <\/p>\n<p>Looks pretty imposing doesn&#8217;t it?  It&#8217;s actually pretty easy to call using CFMX.  <\/p>\n<p>&lt;cfscript&gt;<br \/>\n  myObject = CreateObject(&#8220;java&#8221;, &#8220;com.thirdpartyApp.OtherClass&#8221;);<br \/>\n  \/\/ retrieve the long value from the third party class<br \/>\n  t = CreateObject(&#8220;java&#8221;, &#8220;com.thirdpartyApp.Class&#8221;);<br \/>\n  longValue = t.SOME_CONSTANT;<\/p>\n<p>  \/\/ get a javax.servlet.http.HttpServletRequest object from CFMX<br \/>\n  req = getPageContext().getRequest(); <\/p>\n<p>  \/\/ get a javax.servlet.http.HttpServletResponse object from CFMX<br \/>\n  res = getPageContext().getResponse(); <\/p>\n<p>  myObject.doSomething(req, res, longValue);<br \/>\n&lt;\/cfscript&gt;<\/p>\n<p>One interesting to note is that if you do getClass() on the req and res objects like this:<\/p>\n<p>&lt;cfoutput&gt;#req.getClass()#&lt;\/cfoutput&gt;<br \/>\n&lt;cfoutput&gt;#res.getClass()#&lt;\/cfoutput&gt;<\/p>\n<p>above you get the following class names:<\/p>\n<p>req = jrun.servlet.ForwardRequest<br \/>\nres = coldfusion.jsp.JspWriterIncludeResponse<\/p>\n<p>and although they don&#8217;t look like javax.servlet.http.HttpServletResponse and javax.servlet.http.HttpServletRequest objects, they actually extend the <a href=\"http:\/\/java.sun.com\/webservices\/docs\/ea2\/api\/javax\/servlet\/ServletRequestWrapper.html\">javax.servlet.ServletRequestWrapper<\/a> and <a href=\"http:\/\/java.sun.com\/webservices\/docs\/ea2\/api\/javax\/servlet\/ServletResponseWrapper.html\">javax.servlet.ServletResponseWrapper<\/a> classes, which are wrappers (as their names imply) for the <a href=\"http:\/\/java.sun.com\/webservices\/docs\/ea2\/api\/javax\/servlet\/ServletRequest.html\">javax.servlet.ServletRequest<\/a> and <a href=\"http:\/\/java.sun.com\/webservices\/docs\/ea2\/api\/javax\/servlet\/ServletResponse.html\">javax.servlet.ServetResponse<\/a> interfaces. <\/p>\n<p>Anyway, interesting journey.. great help from <a href=\"http:\/\/www.corfield.org\/blog\/\">Sean Corfield<\/a> for his <a href=\"http:\/\/www.corfield.org\/blog\/archives\/2002_06.html#000228\">post<\/a> about the getClass() method you can use to find out the type of an object and to <a href=\"http:\/\/cfmxplus.blogspot.com\/\">Charlie Arehart<\/a> for his comprehensive <a href=\"http:\/\/www.systemanage.com\/cff\/cf_java.cfm\">Java\/CFMX archive<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m doing some research for an article I&#8217;m writing for Macromedia Devnet (hopefully to be published in May or June). I won&#8217;t go into the details of the article, but part of it deals (tangentially) with CFMX and Java integration. Specifically, I&#8217;m using CFMX to call a relatively simple Java API that consists of a &hellip; <a href=\"https:\/\/cephas.net\/blog\/2003\/04\/10\/cfmx-httpservletrequesthttpservletresponse\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">CFMX &amp; HttpServletRequest\/HttpServletResponse<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,3,2],"tags":[],"_links":{"self":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/349"}],"collection":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/comments?post=349"}],"version-history":[{"count":0,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/349\/revisions"}],"wp:attachment":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/media?parent=349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/categories?post=349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/tags?post=349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}