Asp.net|asp.net occasionally encounters in asp/asp during the development process. NET to implement functionality that was previously implemented in Java, the following is a simple example of how to use this detail:
1. Create Java files:
Use any editor you like to edit the following:
public class Hello
{
public string HelloWorld (string s)
{
if (s = = null)
Return "";
Else
return s;
}
}
Save this file as a Hello.java
2. Compile Java file as class:
Command mode run: Javac Hello.java
3. Copy the compiled Hello.class file to the C:\winnt\java\trustlib directory.
4, create the following file, named Test.asp:
<%
Set javaobject = GetObject ("Java:hello")
msg = Javaobject.helloworld ("Hello World")
Set javaobject = Nothing
Response.Write msg
%>
5, testing:
Create a virtual directory in IIS test, copy test.asp files to this virtual directory, restart IIS, Access http://localhost/test/test.asp in IE, the page displays "Hellow World", indicating success of the call.
ASP.net can be used in the same way as the ASP.
Note: Step 2 compile with a 1.3.x compiler, in 1.4 of the JDK is normal, but I call in Asp/asp.net Show no object for moniker error
6. If you import other jar packages in the Java file, you will need to copy these. jar files to the C:\winnt\java\packages directory in step 3, and--> the Advanced--> system variables in My computer's--> properties, Add the classpath variable whose value is the detailed path to the jar file, such as C:\winnt\java\packages\ldapfilt.jar;c:\winnt\java\packages\ldapjdk.jar;c:\winnt \java\packages\ldapsp.jar;. Separated by semicolons in the middle, end with a decimal point
Above in both Chinese and English Win2000, WinXP test pass