Oops!

Hit the send key by mistake there:

<cfscript>
 try {
        socket = createObject('java','java.net.Socket').init();
  remoteAddress=socket.getRemoteSocketAddress();
  if (not structKeyExists(variables,'remoteAddress')) {
        remoteAddress = -1;
  }
 }
 catch (Any e) {
          writeoutput(e.message);
     remoteAddress=-1;
 }
 writeoutput("#remoteAddress#");
</cfscript>

If the java method can return a null you need to check if the variable exists after assigning it. If it doesn't exist you got a null back.

Spike

Paul Hastings wrote:
Spike wrote:

CF7 already has the ability to do most of this:

<cfset nullValue = JavaCast("null","") />
<cfif not structKeyExists(variables,'nullValue')>
Null Value found.
</cfif>

The only thing it doesn't support is returning a null instead of say a struct or a query.


i think javacast is a special case. you can test for the existence of "nullValue" ok but this sort of thing below bombs. nulledVar is like long gone as far as cf is concerned, even to the catch bits. that output throws an undefined error. or something funky about catch scope, etc.

<cfscript>
try {
    nulledVar=someJavaObjectThatCanReturnNull();
}
catch (Any e) {
    nulledVar="something";
}
writeoutput("#nulledVar#");
</cfscript>


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.


CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at www.mail-archive.com/[email protected]




--

--------------------------------------------
Stephen Milligan
Code poet for hire
http://www.spike.org.uk

Do you cfeclipse? http://cfeclipse.tigris.org


---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]




Reply via email to