BBS水木清华站∶精华区

发信人: UN (蝈蝈), 信区: Java 
标  题: Re: CGI与JAVA通讯问题 
发信站: BBS 水木清华站 (Wed Jul 15 17:35:57 1998) 
 
【 在 zazu (沙祖) 的大作中提到: 】 
∶ 在APPLET中,我想向CGI程序发送请求,然后CGI返回结果。 
∶ 不知哪位高手能够回答。最好提供例程。 
∶ 多谢了!!� 
你的意思是指JAVA调用CGI了。是否可以考虑下面的程序: 
... 
cgirequest="http://~/cgi-bin/add.htm?..."; 
getAppletContext()(.showDocument(new URL(cgirequest)); 
... 
 
-- 
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 202.117.116.5] 
发信人: mah (chip), 信区: Java 
标  题: Re: CGI与JAVA通讯问题 
发信站: BBS 水木清华站 (Fri Jul 17 19:20:24 1998) WWW-POST 
 
【 在 zazu (沙祖) 的大作中提到: 】 
∶ 在APPLET中,我想向CGI程序发送请求,然后CGI返回结果。 
∶ 不知哪位高手能够回答。最好提供例程。 
∶ 多谢了!!! 
∶  
为什么,不试试JAVA SERVLET,这可是纯JAVA的解决方案 
 
-- 
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 162.105.130.77]  
发信人: WHoo (CORBA), 信区: Java 
标  题: Re: CGI与JAVA通讯问题 
发信站: BBS 水木清华站 (Sat Jul 18 04:59:21 1998) 
 
Not everyone hjavqas Java WebServer installed. 
Use POST and URLConnection. 
 
【 在 mah (chip) 的大作中提到: 】 
∶ 【 在 zazu (沙祖) 的大作中提到: 】 
∶ 为什么,不试试JAVA SERVLET,这可是纯JAVA的解决方案 
 
 
-- 
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 166.111.8.88] 
发信人: scaner (静止到流动∝八阶幻方), 信区: Java 
标  题: Re: CGI与JAVA通讯问题 
发信站: BBS 水木清华站 (Sat Jul 18 07:45:06 1998) 
 
纯java的解决方案并不代表他有什么优越性 
何况很多地方都不支持java servlet 
 
觉得用Post,URLConnection足够了,记得以前有个记数器 
的例子就是applet和cgi配合的。 
 
 
【 在 mah (chip) 的大作中提到: 】 
∶ 为什么,不试试JAVA SERVLET,这可是纯JAVA的解决方案 
 
 
-- 
#telnet I.want.to.go 
telnet: Unable to connect to remote host: No Route to host 
 
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 202.119.79.70] 
发信人: waitress (等你 ), 信区: Java 
标  题: Re: CGI与JAVA通讯问题 
发信站: BBS 水木清华站 (Tue Jul 21 23:23:30 1998) 
 
  public void getMyText() { 
        try { 
            url = new URL( "http://www/cgi-bin/test" ); 
            urlConnection = url.openConnection(); 
            inStream = new DataInputStream(urlConnection.getInputStream()); 
            outStream = new DataOutputStream(urlConnection.getOutputStream()); 
             urlConnection.setDoInput(true); 
          // to confirm output to the server            
             urConnection.setDoOutput(true); 
    
            String newText=""; 
            String line; 
            while((line=inStream.readLine()) != null) { 
                newText += line+"\n"; 
            } 
 
            text.setText( newText ); 
        }catch( MalformedURLException ex) { 
            text.setText( "Error" ); 
        }catch( IOException ex) { 
            text.setText( "IO Error" ); 
        } 
 
【 在 zazu (沙祖) 的大作中提到: 】 
∶ 在APPLET中,我想向CGI程序发送请求,然后CGI返回结果。 
∶ 不知哪位高手能够回答。最好提供例程。 
∶ 多谢了!!! 
 
 
-- 
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 202.120.240.76] 
发信人: ifonly (狮子王☆飞了,病了), 信区: Java        
标  题: 用Java向CGI程序实现POST方法. 
发信站: BBS 水木清华站 (Fri Sep  3 11:10:04 1999) 
 
 
以下是向CGI程序实现POST功能的java代码, 
程序非常简单,就不说明了, 
有问题可以来信. 
import java.io.*; 
import java.net.*; 
public class PostToCGI { 
    public static void main(String[] args) throws Exception 
        { 
        BufferedWriter fout = new BufferedWriter(new FileWriter("test1.htm")); 
        String stringToServer0 = URLEncoder.encode("hellohello"); 
        String stringToServer1 = URLEncoder.encode("大家好!"); 
        String stringToServer2 = URLEncoder.encode("好大家!"); 
        URL url = new URL("http://yourserver/cgi-bint/test.asp"); 
        URLConnection connection = url.openConnection();         
        connection.setDoOutput(true); 
        PrintWriter out = new PrintWriter(connection.getOutputStream()); 
out.println("string=" +stringToServer0+"&T1="+stringToServer1+"&S1="+string 
ToServer2);      
        out.close(); 
 BufferedReader in = new BufferedReader(new InputStreamReader(connection.get 
InputStream()));         
        String inputLine; 
        while ((inputLine = in.readLine()) != null)  { 
                System.out.println(inputLine); 
                fout.write(inputLine); 
        } 
        in.close(); 
        fout.close(); 
} 
         
} 
 
-- 
※ 修改:·ifonly 於 Sep  3 11:12:43 修改本文·[FROM:   210.76.97.123] 
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 210.76.97.123] 

BBS水木清华站∶精华区