|
|
Исходный текст программы CallCGI.java
|
Оглавление |
Назад
// ==========================================
// CallCGI.java
//(C) Alexandr Frolov, 1998
// E-mail: frolov@glasnet.ru
// Web: http://www.glasnet.ru/~frolov
// ==========================================
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
public class CallCGI extends Applet
implements ActionListener, Runnable
{
TextArea ta;
Button btnConnect;
private Thread thrConnect = null;
// ============================================
// init
// ============================================
public void init()
{
btnConnect = new Button("Connect");
ta = new TextArea(5, 40);
btnConnect.addActionListener(this);
add(ta);
add(btnConnect);
setBackground(Color.white);
setForeground(Color.black);
}
// ============================================
// run
// ============================================
public void run()
{
URL u;
URLConnection c;
PrintStream ps;
DataInputStream is;
try
{
String szPrivateInfo =
URLEncoder.encode("MyPrivateInfo");
String szReceived;
String szURL =
"http://frolov/scripts/infocgi.exe";
u = new URL(szURL);
c = u.openConnection();
ps = new PrintStream(c.getOutputStream());
ps.println(szPrivateInfo);
ps.close();
is =
new DataInputStream(c.getInputStream());
szReceived = is.readLine();
ta.append(szReceived + "\n");
is.close();
}
catch (Exception ioe)
{
showStatus(ioe.toString());
stop();
}
}
// ============================================
// actionPerformed
// ============================================
public void actionPerformed(ActionEvent e)
{
if(e.getSource().equals(btnConnect))
{
thrConnect = new Thread(this);
thrConnect.start();
}
}
// ============================================
// getAppletInfo
// ============================================
public String getAppletInfo()
{
return "Name: CallCGI";
}
}
|
|
|