Type casting problem with Java Class (bean)
[nobr]I have a simple Java class that I registered with the asp server as a COM used to process credit cards. There is a STRING variable in the class called Amount which, as the name indicates, will contain the dollar value of the transaction.
The problem is that no matter how I try to coerce a value like 45.99 into a string, I receive a Type mismatch error:
Error Type:
Sun ONE ASP VBScript runtime (0x800A000D)
Type mismatch
If I set the value using something like "45.99.56" or "three" (i.e. an obvious string), it works fine in terms of setting the variable.
Here are the code snippets:
<%@LANGUAGE="VBSCRIPT" %>
<%
Dim Authctl
Dim myamount
Dim mytype
Dim objprop
myamount = CStr("55.34")
mytype = TypeName(myamount)
Response.Write"myamount = " & myamount &"<br />mytype = " & mytype &"<br />"
Set Authctl = Server.CreateObject("MyBean.Processor")
With Authctl
.ResetValues
.SrvrIPName ="127.0.0.1"
.CardType ="V"
.TranType ="AU"
.Amount ="45.99.65"
Response.Write .SrvrIPName &"<br />" & .CardType &"<br />" & .TranType &"<br />" & .Amount &"<br />
End With
Set Authctl = Nothing
Response.End
%>
The above produces the following on output:
myamount = 55.34
mytype = String
127.0.0.1
V
AU
45.99.65
Now if I change the above code to substitue the variable myamount for the "45.99.65" :
<%@LANGUAGE="VBSCRIPT" %>
<%
Dim Authctl
Dim myamount
Dim mytype
Dim objprop
myamount = CStr("55.34")
mytype = TypeName(myamount)
Response.Write"myamount = " & myamount &"<br />mytype = " & mytype &"<br />"
Set Authctl = Server.CreateObject("MyBean.Processor")
With Authctl
.ResetValues
.SrvrIPName ="127.0.0.1"
.CardType ="V"
.TranType ="AU"
.Amount = myamount
Response.Write .SrvrIPName &"<br />" & .CardType &"<br />" & .TranType &"<br />" & .Amount &"<br />
End With
Set Authctl = Nothing
Response.End
%>
I get the Type mismatch error.
I looked for any known bugs about type coercion and java but came up empty-handed so far. The odd thing is that if I restart the casp server, the error does not happen until I call the page a couple times; after that, it bails with the Type mismatch error. I have tried to include a Session.Abandon command in the script so as to create a new session each time I invoke the page, but that does nothing.
It's as if after a few calls to the page, the CStr function fails to work when it calls the Java Class and passes the double instead.[/nobr]

