Client Server Observer In Java

Posted on 2009-02-22
Last Modified: 2012-05-06
I want to see a Java example of a Client Server using the Observer design pattern. A server should send client all updates of a variable for example. I am farmilar with the Observer pattern and its Java implementation. Not so good with client server implementation, i have viewed this example so far.

However the ClientThread when I compile it gives me an error saying the catch should not be contained within the try block.

If you have any examples or links that would help me with this more please do let me know.
Question by:namsu55
    LVL 92

    Expert Comment

    there won't be many of those around, why don't you just fix the error in the one you've got? btw why using Observer, its a bit of a dinosaur.


    Author Comment

    Just so I can send some updates to a few GUI's. View the code not sure why its giving me that error. I cant see what is even wrong with it looks fine.
    LVL 92

    Accepted Solution

         try {
            pw.println("Welcome to Java based Server");
          catch(IOException ioe) { }

    in the ClientThread just remove the try catch from the above code
    so it becomes

            pw.println("Welcome to Java based Server");


    Author Comment

    That works just testing this code out.
    LVL 92

    Expert Comment

    but I answered your question didn't I?


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Suggested Solutions

    Title # Comments Views Activity
    Multiple issues with Java 14 37
    dividesSelf challange 15 57
    array6 challenfge 6 48
    strCopies  challenge 17 58
    Upgrading Tomcat – There are a couple of methods to upgrade Tomcat is to use The Apache Installer is to download and unzip and run the services.bat remove|install Tomcat6 Because of the App that we are working with, we can only use Tomcat 6.…
    Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
    The viewer will learn how to implement Singleton Design Pattern in Java.
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now