H
hozen
Unregistered / Unconfirmed
GUEST, unregistred user!
我改写了一个查询域名的程序。想实现在asp中调用编译好的class。
我的步骤如下:
先把下面的程序编译成class文件。
import java.net.*;
import java.io.*;
public class whois
{
public final static int port = 43;
public final static String hostname = "whois.internic.net";
public String s;
public String getInfo(String url){
Socket theSocket;
DataInputStream theWhoisStream;
PrintStream ps;
try{
theSocket = new Socket(hostname,port,true);
ps = new PrintStream(theSocket.getOutputStream());
ps.print(url);
ps.print("/r/n");
theWhoisStream = new DataInputStream(theSocket.getInputStream());
while((s = theWhoisStream.readLine()) != null){
s = s + "/n";
}
theWhoisStream.close();
ps.close();
theSocket.close();
}
catch(IOException e){
System.err.println(e);
}
return s;
}
}
然后将其拷贝到C:/WINNT/java/trustlib下,并运行注册程序
"C:/Program Files/Microsoft Visual Studio/VIntDev98/bin/JAVAREG.EXE" /register /class:whois /progid:javacom.whois
注册成功后,在asp中
<%
set who=server.CreateObject("javacom.whois")
Response.Write who.getInfo("www.sohu.com")
%>
没有输出:(
我的java写的有问题,因为我按以上步骤写个简单的程序就可以执行。如下:
public class javacom
{
public String szHello = "Hello World" ;
public String anyFunc()
{
String n = "As returned by anyFunc !" ;
return n ;
}
}
注册为javacom.text,成功后在asp中写入下代码
<%
set cc= Server.CreateObject("javacom.test")
response.write cc.szHello &
"<br>"
response.write cc.anyFunc &
"<br>"
%>
成功输出字符串。
-------------------------------------------------
还请高手指点。
附上java查询域名的源程序。
import java.net.*;
import java.io.*;
public class whois
{
public final static int port = 43;
public final static String hostname = "whois.internic.net";
public static void main(String[] args){
Socket theSocket;
DataInputStream theWhoisStream;
PrintStream ps;
if(args.length<1){
System.out.println("/n java whois by busyhozen ");
System.out.println("Parameters:");
System.exit(1);
}
try{
theSocket = new Socket(hostname,port,true);
ps = new PrintStream(theSocket.getOutputStream());
for(int i=0;i<args.length;i++){
ps.print(args + " ");
ps.print("/r/n");
theWhoisStream = new DataInputStream(theSocket.getInputStream());
String s;
while((s = theWhoisStream.readLine()) != null){
System.out.println(s);
}
theWhoisStream.close();
ps.close();
theSocket.close();
}
}
catch(IOException e){
System.err.println(e);
}
}
}
我的步骤如下:
先把下面的程序编译成class文件。
import java.net.*;
import java.io.*;
public class whois
{
public final static int port = 43;
public final static String hostname = "whois.internic.net";
public String s;
public String getInfo(String url){
Socket theSocket;
DataInputStream theWhoisStream;
PrintStream ps;
try{
theSocket = new Socket(hostname,port,true);
ps = new PrintStream(theSocket.getOutputStream());
ps.print(url);
ps.print("/r/n");
theWhoisStream = new DataInputStream(theSocket.getInputStream());
while((s = theWhoisStream.readLine()) != null){
s = s + "/n";
}
theWhoisStream.close();
ps.close();
theSocket.close();
}
catch(IOException e){
System.err.println(e);
}
return s;
}
}
然后将其拷贝到C:/WINNT/java/trustlib下,并运行注册程序
"C:/Program Files/Microsoft Visual Studio/VIntDev98/bin/JAVAREG.EXE" /register /class:whois /progid:javacom.whois
注册成功后,在asp中
<%
set who=server.CreateObject("javacom.whois")
Response.Write who.getInfo("www.sohu.com")
%>
没有输出:(
我的java写的有问题,因为我按以上步骤写个简单的程序就可以执行。如下:
public class javacom
{
public String szHello = "Hello World" ;
public String anyFunc()
{
String n = "As returned by anyFunc !" ;
return n ;
}
}
注册为javacom.text,成功后在asp中写入下代码
<%
set cc= Server.CreateObject("javacom.test")
response.write cc.szHello &
"<br>"
response.write cc.anyFunc &
"<br>"
%>
成功输出字符串。
-------------------------------------------------
还请高手指点。
附上java查询域名的源程序。
import java.net.*;
import java.io.*;
public class whois
{
public final static int port = 43;
public final static String hostname = "whois.internic.net";
public static void main(String[] args){
Socket theSocket;
DataInputStream theWhoisStream;
PrintStream ps;
if(args.length<1){
System.out.println("/n java whois by busyhozen ");
System.out.println("Parameters:");
System.exit(1);
}
try{
theSocket = new Socket(hostname,port,true);
ps = new PrintStream(theSocket.getOutputStream());
for(int i=0;i<args.length;i++){
ps.print(args + " ");
ps.print("/r/n");
theWhoisStream = new DataInputStream(theSocket.getInputStream());
String s;
while((s = theWhoisStream.readLine()) != null){
System.out.println(s);
}
theWhoisStream.close();
ps.close();
theSocket.close();
}
}
catch(IOException e){
System.err.println(e);
}
}
}