Results 1 to 18 of 18
  1. #1
    bobo67 is offline Member
    Join Date
    Sep 2010
    Posts
    37
    Rep Power
    0

    Question Client-Server in applet

    hi,
    I have a client-server program which the client is applet and the server is java application.
    I run in eclipse and work.
    when I run my client in browser, and server in eclipse, they don't work. How do I have to run these?
    thx

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    they don't work
    Look in the browser's java console for error messages that explain what the problem is
    Copy and paste the messages here if you have questions.

  3. #3
    bobo67 is offline Member
    Join Date
    Sep 2010
    Posts
    37
    Rep Power
    0

    Default

    it doesn't have error.
    browser show my client file.
    I think my socket doesn't work.my client run up to socket. server doesn't receive any thing from client.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Can you explain how you are executing the applet in a browser? Is there an html file the browser loads? Does the page load ok? Does the applet load ok or is there an error loading the applet?
    Is there an error message in the browser's java console window? THIS IS IMPORTANT!!
    Does you applet print out any messages that show in the java console? If not add a System.out.println("Hi from applet"); to the init() method and see if that prints out in the java console.

  5. #5
    bobo67 is offline Member
    Join Date
    Sep 2010
    Posts
    37
    Rep Power
    0

    Default

    I get a client server code from internet. it's pizza order program.
    First I run client in a program and put the client.class file in my web server. I make a client.html.
    Then I run the server file in eclipse.
    I open the client.html file and it show my client page.
    I order and click on send button. 3 sentences show in page which are in client.class file.
    "Sending Order to server ... Receiving Order Total... Final Total is "
    and stop. client can't receive final total from server.
    In sever side: nothing happen. it doesn't receive order

  6. #6
    bobo67 is offline Member
    Join Date
    Sep 2010
    Posts
    37
    Rep Power
    0

    Default

    in firefox my error console is empty.
    in internet explorer I can't open error console.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    I don't know what an "error console" is. Are you talking about the one for javascript?
    I'm referring to the Java console. You need to find the Java console.

    Here is what one looks like:
    Attached Thumbnails Attached Thumbnails Client-Server in applet-javaconsole.jpg  
    Last edited by Norm; 10-08-2010 at 04:33 PM.

  8. #8
    bobo67 is offline Member
    Join Date
    Sep 2010
    Posts
    37
    Rep Power
    0

    Default

    thx, here's my error:
    java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:2222 connect,resolve)

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Applets can only communicate with the location they were loaded from. Do you load the html with the applet from the localhost server or from a local disk? or where?
    To allow the applet to connect with the localhost, you need to load the applet from the localhost.

    It is possible for you to give your applet permission to do things like use Sockets by adding permissions to the .java.policy file on your PC. You edit the .java.policy file with the policytool program that comes with the JDK.

  10. #10
    bobo67 is offline Member
    Join Date
    Sep 2010
    Posts
    37
    Rep Power
    0

    Default

    my client class and html file are in webserver, but my server run in eclipse...
    Would you please help me how to set that file?
    Last edited by bobo67; 10-08-2010 at 07:37 PM.

  11. #11
    bobo67 is offline Member
    Join Date
    Sep 2010
    Posts
    37
    Rep Power
    0

    Default

    I open it. show this:
    CodeBase <ALL>

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Do you load the html and applet into the browser with a url like this: http://127.0.0.1

    Setting up the .java.policy file takes a bit of doing. Do a Search here and with Google on how to put values in it and where it needs to be.

  13. #13
    bobo67 is offline Member
    Join Date
    Sep 2010
    Posts
    37
    Rep Power
    0

    Question

    hi,
    thx for your help.
    I solved that problem. but now I have another error for another socket.
    java.net.ConnectException: Connection refused: connect
    I don't know what to do. Please help me.
    thx

  14. #14
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Sorry, I don't know why that happened. Perhaps the server didn't want to respond to you.
    Or the ports were wrong.

  15. #15
    bobo67 is offline Member
    Join Date
    Sep 2010
    Posts
    37
    Rep Power
    0

    Question

    my server is listening.
    my client as I said is Applet. in the java code of applet I call another class, this class open socket. Is it problem for this?

  16. #16
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    No, which class calls the Socket shouldn't make a difference.
    Are the server and client on the same PC? Are you using the localhost address?
    Are they ports matched correctly?

  17. #17
    bobo67 is offline Member
    Join Date
    Sep 2010
    Posts
    37
    Rep Power
    0

    Default

    yes, they're on the same PC. yeh

  18. #18
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    If they are using the same port, I don't know what the problem is.
    Is the browser is able to get the html page and the applet code from the server OK?

Similar Threads

  1. Replies: 2
    Last Post: 09-24-2010, 11:31 AM
  2. Replies: 3
    Last Post: 07-29-2009, 04:52 AM
  3. Replies: 2
    Last Post: 10-05-2008, 06:13 PM
  4. Replies: 1
    Last Post: 10-05-2008, 03:12 PM
  5. Identify Client in Socket Client Server Application
    By masadjie in forum Networking
    Replies: 1
    Last Post: 12-20-2007, 09:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •