#1
  1. Introspective
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Nov 2001
    Location
    London, UK
    Posts
    3,317
    Rep Power
    110

    Java applet to call http://192.168.1.45/ - how to enable?


    Guys,

    I'm sure this is a common problem with a common solution. I've read some docs, but not managed yet to get it to work. I want an applet to request a script (php or perl) on my webserver, and capture the string sent back.

    I have bundled my classes into a jar file, and placed the php script into the same directory as the jar file itself. I have also tried digitally signing the jar with jarsigner, altho that shouldn't be required if it's on the same server.

    I also have the following java.policy file in the same folder (ie alongside the .jar and the php script):

    grant{
    permission.java.security.AllPermission;
    };

    The first thing that strikes me is that I don't actually see ANY requests coming in when I tail my apache webserver logs.. the code I'm using to make the request is something like:
    Code:
                try {
                    URL location= new URL("http://192.168.1.45");
                    BufferedReader streamReader= new BufferedReader(new InputStreamReader(location.openStream()));
    
                    String returnedData;
                    while ((returnedData= streamReader.readLine()) != null) {
                        System.out.println(returnedData);  
                    }
                    streamReader.close();
    
                } catch (MalformedURLException malfexec) {
                    System.out.println(malfexec);
                }
    I have simplified the problem as much as possible. I guess the first thing would be to get some requests in to the webserver - even a 404 log would be better than nothing

    christo
    This is me: http://chris.uk.com
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2003
    Posts
    778
    Rep Power
    12
    hi,
    tail will not reveal anything because the request is not coming through. Same server means the exact same server and a folder that is not above the folder that delivers te applet in some cases.

    You will find this article at http://www.raditha.com/java/sandbox/ helpfull if you want to make use of signed applets.

    all the best
    A lean and mean secure FTP applet with GUI. Just 150 kb in size
    http://www.radinks.com/sftp
  4. #3
  5. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    If the applet is located int he web root and you want to call the index.php (or whatever) of the web root, then try using
    Code:
    try {
                    URL location= getCodeBase();
                    BufferedReader streamReader= new BufferedReader(new InputStreamReader(location.openStream()));
    
                    String returnedData;
                    while ((returnedData= streamReader.readLine()) != null) {
                        System.out.println(returnedData);  
                    }
                    streamReader.close();
    
                } catch (MalformedURLException malfexec) {
                    System.out.println(malfexec);
                }
    ...and see what it does. Also, look in your java console on the client. Is there a stack trace?
    ~Nemi

    Before posting did you try:
    [ Javadocs | Google ]

Similar Threads

  1. calling java.sql.* Java package from PHP
    By IrinaIonela in forum Java Help
    Replies: 3
    Last Post: February 3rd, 2004, 11:51 AM
  2. how can my java applet to communicate with db
    By eforce in forum Java Help
    Replies: 2
    Last Post: July 20th, 2003, 07:06 PM
  3. Java Applet & DataSocket
    By anderaus in forum Beginner Programming
    Replies: 2
    Last Post: July 5th, 2002, 03:20 AM
  4. Replies: 1
    Last Post: February 28th, 2002, 02:24 PM
  5. calling java.sql.* Java package from PHP
    By IrinaIonela in forum PHP Development
    Replies: 0
    Last Post: February 28th, 2002, 01:45 PM

IMN logo majestic logo threadwatch logo seochat tools logo