Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [java] sockety | applet, NetBeans IDE 6.1
uzytkowicz
post 29.06.2008, 17:35:51
Post #1





Grupa: Zarejestrowani
Postów: 41
Pomógł: 0
Dołączył: 10.04.2007

Ostrzeżenie: (30%)
XX---


skrypt się kompiluje i uruchamia i działa poprawnie w NetBeans .. ale jak odpalam go w przeglądarce to mam "Loading Java Applet Failed" sadsmiley02.gif ?


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



P.S uruchamiam go tym generowanym automatycznie NewApplet.html znajdującym się we folderze Nazwa_Projektu/build/*.*

Ten post edytował uzytkowicz 29.06.2008, 17:38:21


--------------------
[ZMODEROWANO]
Go to the top of the page
+Quote Post
dr_bonzo
post 29.06.2008, 17:54:44
Post #2





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

Ostrzeżenie: (0%)
-----


Zgaduje:
aplety nie moga laczyc sie zinnymi serwerami niz z tymi z ktorych pochodza, a ty laczysz sie z onetem [dopiero jak podpiszesz apleta to jest to mozliwe]. Wiec pewnie dostajesz security exception albo cos podobnego.


--------------------
Nie lubię jednorożców.
Go to the top of the page
+Quote Post
uzytkowicz
post 29.06.2008, 17:56:43
Post #3





Grupa: Zarejestrowani
Postów: 41
Pomógł: 0
Dołączył: 10.04.2007

Ostrzeżenie: (30%)
XX---


jak podpisać taki applet ? winksmiley.jpg


--------------------
[ZMODEROWANO]
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.07.2025 - 11:35