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:

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.

One Response to Remember that JSP eq Java

  1. Pussy Cat says:

    The server I’m working on also has the limitations applied to ColdFusion. I gotta try your idea – I’ll let you know if it works out!