2012-03-05 34 views
1

我有以下問題,這個簡單的ASP頁:無法從ASP頁面調用Java方法:

<% 
Dim javaTestObj set javaTestObj = GetObject("java:test") 

if javaTestObj.mstrLogin("pepe", "pepe") then 

    Response.write("It Works!") 

end if 
%> 

的Java類如下:

public class test{ 
String pepe; 

public test() 
{ 
    pepe="pepepepe"; 
} 

public boolean mstrLogin(String usname, String uspass) 
{ 
    if((usname+uspass)==pepe) 
     return true; 
    else 
     return false; 
}} 

我有編譯後的.class在我讀過的每個目錄中都應該是(C:\ ClassPath \; C:\ windows \ java \ trustedlib \,並且與asp頁面在同一目錄中),但是我得不到結果=(

它將如何工作?我使用IIS和瀏覽器給我此錯誤:

錯誤類型: 微軟VBScript編譯錯誤(0x800A0401) 預期指令結束: /login/pruebajava.asp,第2行,第16欄第 昏暗javaTestObj設置javaTestObj = GetObject的 (」 Java的:測試「) ---------------^

+0

任何人都可以幫助我嗎? =( – Pedrobotella 2012-03-05 10:49:12

回答

0

這可能是你剛無意中省略冒號(:)字符,但第一行應爲

Dim javaTestObj : set javaTestObj = GetObject("java:test") 


因爲在傳統的ASP你不能申報,並設置一個變量在同一個語句

Dim myVariable = "hello World" '//Error! Not allowed. 
Dim myOtherVar 
myOtherVar  = "hello World" '//OK 
Dim myVar : myVar = "Hello World" '//OK 
+0

好的,我明天在工作時試試,非常感謝! – Pedrobotella 2012-03-05 17:42:32

+0

現在它顯示「無效的語法」錯誤=( – Pedrobotella 2012-03-06 09:08:25

+0

在哪一行發生錯誤? – David 2012-03-06 11:18:35