HyperTextMatters
11 August 2005
 
ColdFusionMX7 Servlet Development
Post a comment (login required)
Did you know you can develop Java servlets using ColdFusion MX?  I found it easiest to start by enabling ColdFusion "standalone" mode, which however may not be best practice.  The following assumes you installed ColdFusion under windows, to the default "CFusionMX7" directory:

Modify "C:\CFusionMX7\runtime\servers\coldfusion\SERVER-INF\jrun.xml".  Near the bottom, in the block captioned "Built-in JRun Web Server", ensure the following is set:

<attribute name="deactivated">false</attribute>

This enables ColdFusion locally at: http://localhost:8500

Now just long-established servlet configuration and development follows.  ColdFusion's servlet functionality lies within "C:\CFusionMX7\runtime\lib\jrun.jar" so specify it on the class path when compiling.  Put your compiled servlet class in "C:\CFusionMX7\wwwroot\WEB-INF\classes".   Add the appropriate "servlet" and "servlet-mapping" blocks to "C:\CFusionMX7\wwwroot\WEB-INF\web.xml", in particular specifying a url-pattern beginning with "/servlets/".  Restart ColdFusion and your servlet should be available at a URL such as:

http://localhost:8500/servlets/CfmxServletDemo

In months to come we will explore WHY you might want to develop servlets under ColdFusion MX
Posted by htmatters at 7:40 AM | Comments (2)
 
Subscription Options

You are not logged in, so your subscription status for this entry is unknown. You can login or register here.

Re: ColdFusionMX7 Servlet Development
Followed all instructions, and servlet opens but won't display it says:

The image ?http://localhost:8500/servlets/simple? cannot be displayed, because it contains errors.

Note that IE wont even go that far, but Mozilla displays the error message above.

The log initially said something about favicon.ico, but I added one and now get zero errors in the log. Any help would be appreciated. The servlet in reference is a simple hello world and was tested on its own and worked.

Posted by frank on April 6, 2006 at 11:54 AM

Re: ColdFusionMX7 Servlet Development
From the article:

Restart ColdFusion and your servlet should be available at a URL such as:

http://localhost:8500/servlets/CfmxServletDemo

--------
this should read

http://localhost:8500/servlet/CfmxServletDemo

...I dont even think you need to map it in the web.xml unless you have some other servlet settings disabled. I had it mapped as /servlets/servletname and it would cause the error of not displaying in the browser (although it was recognized)...but as soon as i referenced it by servlet/servlet name (note the singularity of the word servlet) the default cold fusion jrun settings enabled it to be displayed properly. Other than that, thanks for the good article...it was the only one I could find that showed how to make this work by including all the steps in one spot.

Posted by frank on April 6, 2006 at 2:39 PM

Post a comment (login required)