Interaction between Java and ASP (1)

Source: Internet
Author: User

JAVA has special optimizations for network applications. Therefore, it may be more suitable for advanced network applications with ASP.

Before you start, you need to prepare:

-Personal Web Server or IIS

-Microsofts Java SDK 3.2 or higher

-Microsofts latest Java Virtual Machine

You can get their latest version from Microsoft's website http://microsoft.com/java.

Now let's start our code journey. Open a notepad or another text editor. Let's get some basic concepts from a simple "Hello World" example. The following is the Java code:

Public class hello

{

Public static void main (String [] args)

{

// Retain the empty process body-prevents compilation errors

}

Public String SayHello ()

{

Return "Hello World ";

}

}

Very simple, right? Now, save the edited code to the directory where the jvc.exe file is located (it should be the Bin directory under the SDK ). Name the file hello. java. Note that the name must be consistent with the class defined in the Code, and be case sensitive. Otherwise, a compilation error may occur. Then enter the following command in the command line to compile:

Jvc hello. java

A file named hello. class is displayed in that directory, which is a compiled Java class file. Copy it to C: WinntJavaTrustLib. Now we can call this file in ASP. The Code is as follows:

<%

Set javaObject = GetObject ("java: hello ")

StrResult = javaObject. SayHello ()

Response. Write (strResult)

Set javaObject = nothing

%>

Of course, this is just an experiment and can't do anything. However, we can get some basic ideas. Create a Java class and place it in the C: WinntJavaTrustLib directory for ASP to access Java objects. Then, use GetObject ("java: hello") in ASP to get reference to the Java object. There is nothing left, but simply calling the attributes of the object can be done. As we will see later, this method has its feasibility. What a Java class can do is not ActiveX. However, ActiveX is the original configuration of ASP. JAVA does not know whether it has any compatibility issues. However, we will only discuss the feasibility of this method here. The rest may be put aside for the moment.

The basic function of the following is to extract the required information from other websites, and then display it on your own webpage. If you steal the day, you will not just be confused.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.