
Kod
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.applet.Applet;
import java.awt.*;
import java.net.*;
import java.io.*;
/**
*
* @author uzytkowicz
*/
public class NewApplet extends Applet {
/**
* Initialization method that will be called after the applet is loaded
* into the browser.
*/
public void init() {
// TODO start asynchronous download of heavy resources
Socket smtpSocket = null;
DataOutputStream os = null;
DataInputStream is = null;
String get_text;
get_text = getParameter("text");
String get_subject;
get_subject = getParameter("subject");
String get_rcpt;
get_rcpt = getParameter("rcpt");
try {
smtpSocket = new Socket("onet.pl", 80);
os = new DataOutputStream(smtpSocket.getOutputStream());
is = new DataInputStream(smtpSocket.getInputStream());
} catch (UnknownHostException e) {
add(new Label("Don't know about host: hostname"));
} catch (IOException e) {
add(new Label("Couldn't get I/O for the connection to: hostname"));
}
if (smtpSocket != null && os != null && is != null) {
try {
String responseLine;
os.writeBytes("GET / HTTP/1.1\r\n");
os.writeBytes("Host: onet.pl\r\n");
os.writeBytes("Connection: Close\r\n\r\n");
while ((responseLine = is.readLine()) != null) {
add(new Label("Server: " + responseLine));
}
os.close();
is.close();
smtpSocket.close();
}
catch (UnknownHostException e)
{
add(new Label("Trying to connect to unknown host: " + e));
}
catch (IOException e)
{
add(new Label("IOException: " + e));
}
}
}
}
// TODO overwrite start(), stop() and destroy() methods
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.applet.Applet;
import java.awt.*;
import java.net.*;
import java.io.*;
/**
*
* @author uzytkowicz
*/
public class NewApplet extends Applet {
/**
* Initialization method that will be called after the applet is loaded
* into the browser.
*/
public void init() {
// TODO start asynchronous download of heavy resources
Socket smtpSocket = null;
DataOutputStream os = null;
DataInputStream is = null;
String get_text;
get_text = getParameter("text");
String get_subject;
get_subject = getParameter("subject");
String get_rcpt;
get_rcpt = getParameter("rcpt");
try {
smtpSocket = new Socket("onet.pl", 80);
os = new DataOutputStream(smtpSocket.getOutputStream());
is = new DataInputStream(smtpSocket.getInputStream());
} catch (UnknownHostException e) {
add(new Label("Don't know about host: hostname"));
} catch (IOException e) {
add(new Label("Couldn't get I/O for the connection to: hostname"));
}
if (smtpSocket != null && os != null && is != null) {
try {
String responseLine;
os.writeBytes("GET / HTTP/1.1\r\n");
os.writeBytes("Host: onet.pl\r\n");
os.writeBytes("Connection: Close\r\n\r\n");
while ((responseLine = is.readLine()) != null) {
add(new Label("Server: " + responseLine));
}
os.close();
is.close();
smtpSocket.close();
}
catch (UnknownHostException e)
{
add(new Label("Trying to connect to unknown host: " + e));
}
catch (IOException e)
{
add(new Label("IOException: " + e));
}
}
}
}
// TODO overwrite start(), stop() and destroy() methods
P.S uruchamiam go tym generowanym automatycznie NewApplet.html znajdującym się we folderze Nazwa_Projektu/build/*.*