简体   繁体   中英

Unable to call java methods from asp pages:

i have the following problem with this simple asp page:

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

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

    Response.write("It Works!")

end if
%>

the Java class is the following:

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;
}}

I have the compiled .class in every directory i've read it should be (C:\\ClassPath\\; C:\\windows\\java\\trustedlib\\ and in the same directory as the asp page) but i get no results =(

Any ideas of how it would work? I'm using IIS and the browser gives me this error:

Error type: Microsoft VBScript compilation error (0x800A0401) expected instruction end: /login/pruebajava.asp, line 2, column 16 Dim javaTestObj set javaTestObj = GetObject ("java:test") ---------------^

It might be that you just accidently omitted the colon (:) character, but the first line should read

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


because in classic ASP you are not allowed to declare and set a variable in the same statement

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM