Remember that JSP eq Java

I was talking to someone last week who needed to use some Java in his ColdFusion application, but couldn’t because of limitations with his hosting provider’s configuration which prevented him from making changes to the ColdFusion server’s classpath. I actually don’t know how much freedom developers who use shared hosting environments have when it comes to integrating Java and ColdFusion (perhaps some people can comment here), however it occurred to me that one possible work-around is to embed all your Java in JSPs (assuming the hosting provider is using ColdFusion Enterprise). JSPs get compiled into Java classes, so as long as you are doing something relatively simple, there is really no reason why you can’t simply include your Java between scriptlet tags. Scriptlet tags look like this:

<%
// java code here
%>

You can declare members (methods and variables) using declaration tags, like this:

<%!
String foo = "bar";
private String getFoo()
{
return foo;
}
%>

Use an expression tag to access members:

<%= getFoo() %>

For an explanation of all JSP tags, see:
http://java.sun.com/products/jsp/syntax/1.2/syntaxref12.html

Again, you’re not going to write an entire application like this (eventually, you are going to need access to the classpath), but in a pinch, you might find this technique useful.