Major difference from ColdFusion 9 to ColdFusion 10 is the underlying architecture. ColdFusion 9 uses JRun as the underlying architecture, whereas ColdFusion 10 and higher version use Tomcat.
Due to this, the way servlets used to configure has changed slightly. Configuring servlet with ColdFusion 10 and later versions is no more a challenge. Here is a sample servlet to test the functionality. Here are the steps to implement:-
- Place the Servlet.cfm in your webroot of your application.
- Place the NewServlet.class file at \ColdFusion10\cfusion\wwwroot\WEB-INF\classes\. If the class file doesn’t work, then compile the NewServlet.java with java 7 and place the compiled class file at the mentioned location.
- Add the following in \ColdFusion10\cfusion\wwwroot\WEB-INF\web.xml and save the file.
<servlet>
<description></description>
<display-name>NewServlet</display-name>
<servlet-name>NewServlet</servlet-name>
<servlet-class>NewServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>NewServlet</servlet-name>
<url-pattern>/NewServlet</url-pattern>
</servlet-mapping>
4. Restart the “ColdFusion 10 Application Service” and browse to http://ip:port/NewServlet.cfm (This is not the internal port, but your website port). Default port is 80.
If the web page appears as mentioned below, then it confirms the Servlet functionality. Now you are good to go ahead and test your servlets.
The same steps are applicable for ColdFusion 11 as well.
Note: – If you get Error 500 after applying the steps, then the problem is with your ColdFusion JRE version. Compile the NewServlet.java with the Java version, same as of your ColdFusion or higher.