Get client Id on server side.

Hi,
I hace a scenario where there are 4 dynamic regions where taskFlows circulate at runtime. The problem is that I have a pageFragment in on off the taskFlow which includes a pie chart. This pie chart needs to exported as image when a button is clicked inside the pageFragment. This requires the clientId (relative to the region currently occupied) of the pieChart component to be used in server side as
FacesContext fctx = FacesContext.getCurrentInstance();
UIViewRoot root = fctx.getViewRoot();
root.invokeOnComponent(fctx,*clientId*,new DvtContextCallBack());
Is this possible somehow to get the clientId in sever side to do the above operation dynamically ?
Regards,
Vijai

Bump I found the solution myself,
UIComponent copm = findComponentInRoot("pieGraph1");
System.out.println(copm.getClientId(facesContext));
* Locate an UIComponent in view root with its component id. Use a recursive way to achieve this.
* @param id UIComponent id
* @return UIComponent object
public static UIComponent findComponentInRoot(String id) {
UIComponent component = null;
FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext != null) {
UIComponent root = facesContext.getViewRoot();
component = findComponent(root, id);
return component;
* Locate an UIComponent from its root component.
* Taken from http://www.jroller.com/page/mert?entry=how_to_find_a_uicomponent
* @param base root Component (parent)
* @param id UIComponent id
* @return UIComponent object
public static UIComponent findComponent(UIComponent base, String id) {
if (id.equals(base.getId()))
return base;
UIComponent children = null;
UIComponent result = null;
Iterator childrens = base.getFacetsAndChildren();
while (childrens.hasNext() && (result == null)) {
children = (UIComponent)childrens.next();
if (id.equals(children.getId())) {
result = children;
break;
result = findComponent(children, id);
if (result != null) {
break;
return result;
}

Similar Messages

  • How to get MAC Address for maintaning unique client id at server side?

    Hi All,
    Can somebody tell how can i get MAC id for maintaing Unique client id at server.
    or is there any alternative way to do this?
    Thanks in advance..
    CK

    Usually people just use cookies for that.

  • How to automate accept client of the server side?

    Hi.....
    I am a beginner of using J2ME to developing my final year project. I have some problem of using bluetooth packet. I can't accept again the client message when the server accepted before. Any one can solve my problem? How can I using the loop or timer to accept the client message without using acceptAndOpen() packet? Thank a lot.....
    The sample code is here:
    - Server side
    public class BluetoothServer implements Runnable {
         private GameMIDlet gameMIDlet;
         private HandleSetting setting;
         private HandleScore score;
         private ScreenGame screenGame;
         private int playerMethod;
         //private GUIGameServer guiGameServer;
    StreamConnectionNotifier notifier;
    StreamConnection conn;
    LocalDevice localDevice;
    ServiceRecord serviceRecord;
    InputStream input;
    OutputStream output;
    private boolean isInit;
    private boolean isReady;
    private static String serverUrl = "btspp://localhost:" + ScreenMultiPlay.SHARE_UUID + ";name=GameServer;authorize=true";
    public BluetoothServer(GameMIDlet gameMIDlet,HandleSetting setting, HandleScore score, int playerMethod) {
         this.gameMIDlet = gameMIDlet;
    this.setting = setting;
              this.score = score;
              this.playerMethod = playerMethod;
         isReady = false;
    isInit = false;
    Thread accepterThread = new Thread(this);
    accepterThread.start();
    public void run() {
    if (!isInit) {
    // Initialization is done in the thread to avoid dead lock 'isInit' ensures it is done once only
    try {
    conn = null;
    localDevice = LocalDevice.getLocalDevice();
    localDevice.setDiscoverable( DiscoveryAgent.GIAC );
    notifier = (StreamConnectionNotifier)Connector.open(serverUrl);
    } catch (BluetoothStateException e) {       
    System.err.println( "BluetoothStateException: " + e.getMessage() );
    } catch (IOException e) {       
    System.err.println( "IOException: " + e.getMessage() );
    isInit=true;
    System.out.println( "Starting Echo Server" );      
    try {
    System.out.println("\n\nServer Running...");
    isReady=true;
    if (isReady) {
         try {
                        screenGame = new ScreenGame(this.gameMIDlet,this.setting,this.score,playerMethod);
              screenGame.start();
    Display.getDisplay(gameMIDlet).setCurrent(screenGame);
                   } catch(Exception e) {
                        gameMIDlet.showErrorMsg(null);
    // Pauses thread until Transmission occurs
    conn = notifier.acceptAndOpen();
    // Read Data Transmission
    String msg = ScreenMultiPlay.readData(conn);
    System.out.println("Received Message from Client: " + msg);
    // Send Back a Message
    msg = "Hello Back from Server";
    output = conn.openOutputStream();
    output.write(msg.length()); // length is 1 byte
    output.write(msg.getBytes());
    output.close();
    } catch (Exception ex) {
    System.err.println("Bluetooth Server Running Error: " + ex);     
    public void destroy() {
    //isClosed = true;
    // finilize notifier work
    if (notifier != null) {
    try {
    notifier.close();
    isInit=false;
    } catch (IOException e) {} // ignore
    // wait for acceptor thread is done
    /*try {
    accepterThread.join();
    } catch (InterruptedException e) {} // ignore*/
    -Client side
    class BluetoothClient implements DiscoveryListener {
         private GameMIDlet gameMIDlet;
         private HandleSetting setting;
         private HandleScore score;
         private ScreenGame screenGame;
         private int playerMethod;
    private DiscoveryAgent discoveryAgent;
    private RemoteDevice[] remoteDevices;
    private UUID[] uuidSet;
    private String serviceUrl;
    public BluetoothClient(GameMIDlet gameMIDlet,HandleSetting setting, HandleScore score, int playerMethod) {
    this.gameMIDlet = gameMIDlet;
    this.setting = setting;
              this.score = score;
              this.playerMethod = playerMethod;
    try {
    LocalDevice localDevice = LocalDevice.getLocalDevice();
    discoveryAgent = localDevice.getDiscoveryAgent();      
    discoveryAgent.startInquiry(DiscoveryAgent.GIAC, this);
    //-----go to deviceDiscovered()-----------------
    } catch (Exception e) {
    System.out.println(e);
    public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {
    try {
    // Get Device Info
    System.out.println("Device Discovered");
    System.out.println("Major Device Class: " + cod.getMajorDeviceClass() + " Minor Device Class: " + cod.getMinorDeviceClass());
    System.out.println("Bluetooth Address: " + btDevice.getBluetoothAddress());
    System.out.println("Bluetooth Friendly Name: " + btDevice.getFriendlyName(true));
    // Search for Services
    uuidSet = new UUID[1];
    uuidSet[0] = ScreenMultiPlay.SHARE_UUID;
    int searchID = discoveryAgent.searchServices(null,uuidSet,btDevice,this);
    //-------------go to inquiryCompleted()----------------------
    } catch (Exception e) {
    System.out.println("Device Discovered Error: " + e);     
    public void inquiryCompleted(int discType) {
    System.out.println("InquiryCompleted");
    //---------------go to servicesDiscovered()------------------------
    public void servicesDiscovered(int transID, ServiceRecord[] servRecord) {
    System.out.println("ServicesDiscovered");
    // in this example there is only one service
    for(int i=0;i<servRecord.length;i++) {      
    serviceUrl = servRecord.getConnectionURL(0,false);
    //---------------go to serviceSearchCompleted()--------------------
    public void serviceSearchCompleted(int transID, int responseCode) {   
    if(responseCode == SERVICE_SEARCH_ERROR)
    System.out.println("SERVICE_SEARCH_ERROR\n");
    if(responseCode == SERVICE_SEARCH_COMPLETED) {
    System.out.println("SERVICE_SEARCH_COMPLETED\n");
    System.out.println("Service URL: " + serviceUrl);
    StreamConnection conn = null;
    try {
         String msg = "Say Hello World";
    conn = (StreamConnection)Connector.open(serviceUrl);
    OutputStream output = conn.openOutputStream();
    output.write(msg.length());
    output.write(msg.getBytes());
    output.close();
    System.out.println(ScreenMultiPlay.readData(conn));
    } catch (Exception ex) {
         System.out.println(ex);
    } finally {
         try {
         conn.close();
         } catch (IOException ioe) {
         System.out.println("Error Closing connection " + ioe);
    if(responseCode == SERVICE_SEARCH_TERMINATED)
    System.out.println("SERVICE_SEARCH_TERMINATED\n");
    if(responseCode == SERVICE_SEARCH_NO_RECORDS)
    System.out.println("SERVICE_SEARCH_NO_RECORDS\n");
    if(responseCode == SERVICE_SEARCH_DEVICE_NOT_REACHABLE)
    System.out.println("SERVICE_SEARCH_DEVICE_NOT_REACHABLE\n");

    This question isn't logical at all. You don't execute javascript on the server. But if you want to waste time on it. .. look at Rhino http://www.mozilla.org/rhino/
    Best of luck...

  • When I open a file in Firefox, how do I get it to include server side inserts

    <blockquote>Locking duplicate thread.<br>
    Please continue here: [/questions/755399]<br>
    Thanks - c</blockquote><br>
    I like to test my html before putting on my server; I do this
    by using FireFox / File / Open File and pointing to the file
    to open; the filenames all end in .shtml, but server side includes
    are not processed; is this a Firefox issue or a Win XP issue?
    (Win XP, SP3)

    You can't use File > Open File to process server side includes. That will only work if you use File > Open Location and if there is a server that can process the file. If you use File > open File then you open that file directly in Firefox (bypassing a server) and only the HTML code will be processed and not SSI code.
    http://encyclopedia.thefreedictionary.com/Server+Side+Include

  • How to get the client certificate at server side

    hi, this is ravikiran
    I am working on a project which requires, receiving a signed file from the client side and verify whether the file is signed by a valid certificate that is there in the servers keystore.
    I have no idea how to do this.
    can anyone help me.
    thanx in advance.

    [sorry, deleted irrelevant wrong answer]

  • How to get the client identity from the certificate at server side

    hi, this is ravi kiran,
    I am working on a project which requires, receiving a signed file from the client side and verify whether the file is signed by a valid certificate that is there in the servers keystore.
    How can i get the client certificate at server side and check with the certificates already present in the servers keystore.
    i have no idea how to do this
    can any one help me
    thanx in advance

    Hi Ravi, did you get any answer to your question ?
    I'm also after a similar problem, please share your solution, if you have any.

  • How to get the publish method with server side actionscript?

    We publish this way at client side:
    ns.publish(name, howToPublish);
    How to get this howToPublish at server side?
    application.onPublish = function(){
        //how to know whether the stream's publishing method(live,record,append) here?

    I am not sure whether you can know mode of publish via SSAS, best way would be to use Authorisation Plug-in which can intercept you publish request and get the information which you need - in this case mode of publishing.

  • How do I define server-side spam rules with Yosemite & Server 4

    Really surprised that this isn't functionality available in the server UI. Poking around in the dovecot/spamassassin docs imply this is possible using sieve, but the configuration looks more complex than I'd like to have to figure out on my own. It seems that sieve might be possible to use. In /Library/Server/Mail/Config/dovecot/conf.d, the option sieve_dir is uncommented, pointing to /Library/Server/Mail/Data/rules/%u. That seems to imply I could create user directories there and apply some sieve rules, has anyone tried this?
    I'd rather not do user-specific rules, I'd prefer to use the default and attempt to move all spam into a spam folder for each user.
    I've seen notes that the webmail client Roundcube provided server-side rules, but I really don't need the web mail client, and various search results seem to raise questions about whether Roundcube is compatible with Sever 4 / Yosemite.
    Any help would be appreciated...

    Was able to get it working with some digging. The basic summary is that you need to create a rules directory for each mail user, and then add a sieve rule in each of the directories you create. I did this manually, which is manageable because I'm using OS X server for my household, and we don't add members to my household that often... :-). Summary of the steps:
    1) Each user has a directory in /Library/Server/Mail/Data/mail that is in UUID format (long hex string with sections broken by - characters).
    2) For each of the users you identify in (1), create an equivalent UUID directory in /Library/Server/Mail/Data/rules
    3) Create a file named "dovecot.sieve" in each of the directories you created in (2). For a basic rule that moves mail marked by SpamAssassin as spam to the Junk folder that Mail.app should create by default, you can use the following:
         require ["fileinto"];
         # rule:[SPAM]
         if header :contains "X-Spam-Flag" "YES" {
                 fileinto "Junk";
    4) Ensure that all of the directories/files are owned by _dovecot. I marked dovecot.sieve as executable, but I'm not sure that was necessary.
    5) Once you've done steps 1-4, you should start to see evidence that sieve is being used for delivery of mail in /Library/Logs/Mail/mailinfo.log. Grep for "sieve" in that to see activity. If there are errors, you'll likely see notices that there are sieve logs being created in the rules directories you set up in (2). I ran into errors for at least one account that didn't have a Junk folder created; if you hit that just have the user create a folder named Junk to clear it up.
    Hope this helps others...

  • Error while saving a workflow via sharepoint designer: Server-side activities have been updated. You need to restart SharePoint Designer to use the updated version of activities.

    While saving a workflow using SharePoint designer on a SharePoint site, I get the following error: 
    Server-side activities have been updated. You need to restart SharePoint Designer to use the updated version of activities.
    Steps to recreate error:
    Login to the WFE server hosting IIS and workflow manager, open SharePoint Designer 2013 and login to a SharePoint site.
    Access the list using SharePoint Designer 2013, in the workflow section, click new workflow. 
    In the new workflow dialog, enter workflow details, click save (see screenshot below).
    Error message is displayed as below:
    After restarting SharePoint Designer, the saved workflow is not seen in the site/workflows or list/workflow section.
    Workaround
    When the above steps are repeated while accessing the site via SPD from any other box besides the WFE/Workflow manager host server, the error is not encountered and its possible to save/publish workflows.
    Notes
    Workflow Manager 1.0 is installed.
    The site has been registered with Workflow manager using Register-SPWorkflowService
    cmdlet.
    Any clue on why is this happening?

    Hi Vivek,
    Please close your SharePoint Designer application, clear/delete the cached files and folders under the following directories from your server installed SharePoint Designer, then check results again.
    <user profile>\appdata\roaming\microsoft\SharePoint Designer\ProxyAssemblyCache
    <user profile>\appdata\local\microsoft\websitecache\<sitename>
    http://www.andreasthumfart.com/2013/08/sharepoint-designer-2013-server-side-activities-have-been-updated/
    Thanks
    We are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Server Side activties have been updated. You need to restart SharePoint Designer to use the updated version of activities.

    Hello,
    I have the following scenario for the installation of EPM 2013 environment:
    1 Server running Windows 2008 R2 SQL Server 2008 R2 Service Pack 2
    1 Windows Server 2008 R2 Standard SP1, running Sharepoint 2013 Enterprise (Standard Initially installed and then migrated to the Enterprise in order to install Project Server 2013), Project Server 2013 and Workflow 1.0 (2013).
    After configuring and validating the configuration of Workflow 1.0 by http://server_name.example.com:12291 page and also check the Application Services in Central Administration and receive the Workflow Status = Connected.
    Alright, but when I run the SPD 2013 RTM to test the creation of Sharepoint Workflow 2013, I get the following warning:
    "Server Side activties have been updated. You need to restart SharePoint Designer to use the updated version of activities."
    I've tried:
    a. Restart SPD2013;
    b. Restart Server 2013 and Sharepoint Workflow 1.0;
    c. Reinstall and reconfigure Workflow 1.0
    And the message is always displayed, preventing the use of Workflow Sharepoint 2013.
    Can anyone help me, I'm in the middle of a deployment to a customer.
    Print of alert

    How did you uninstalledLanguage Pack from SharePoint 2013 ? when I googled it I found that language pack cannot be uninstall@
    http://technet.microsoft.com/en-us/library/cc262108.aspx
    "If you no longer have to support a language for which you have installed a language pack, you can remove the language pack by using the Control Panel. Removing a language pack removes the language-specific site
    templates from the computer. All sites that were created that have those language-specific site templates will no longer work (the URL will produce a HTTP 500 - Internal server error page). Reinstalling the language pack will make the site functional again.
    You cannot remove the language pack for the version of SharePoint 2013 that you have installed on the server. For example, if you are running the Japanese version of SharePoint 2013, you cannot uninstall the Japanese language support for SharePoint 2013."

  • JNI via Server-Side Language

    I'd like to use the following post as a reference: http://72.5.124.102/thread.jspa?threadID=788137&messageID=4479784
    "The DLL will remain loaded between calls, so if you use a global variable to store the connection then it should be ok. "
    Of course this makes logical sense. However, JNI doesn't have a handle from my understanding... JNI looks like this:
    private native void nativeMethodInvoke();
    static {
        System.load(path+dllName) // many alts to this, but yea.
    // somewhere in main thread....
    SelfClass varRefToSelf=new SelfClass();
    // where SelfClass is the current class running.
    // This doesn't make sense to me, considering usage of 'this' - so if anyone can explain that, I would greatly appreciate it.
    varRefToSelf.nativeMethodInvoke();So.... am I supposed to keep a global reference within my class, to itself?!?
    The actual problem is that I'm using a server-side language to invoke Java, and thus C++ via JNI. However, the server-side language is creating a new instance of the JAR upon each invocation. So my plan was to pass a reference to the module handle, and somehow manage to get that back to server-side language, and then furthermore back to Java JNI. Am thinking about moving to a servlet instead, since this doesn't appear to be possible - as unfortunate as that is.
    Would SingleThreadModel work in this case? Or should I have C++ thread itself, so when Java makes a call, I can let C++ handle data by forwarding to correct module in memory? Assuming the above mentioned post is accurate, then the DLL, when loaded by Java, will stay in memory until unloaded. If the jvm is exiting after each server-side invocation, I must assume multiple instances of the dll are being created. So, am thinking this prospect will work... servlets aside...
    Any help is appreciated. I clearly do not understand JNI as well as I should.
    *Edit:
    I have already tried this, and found that C++ DLL's thread is definitely active in memory post-jvm exit. The DLL also appears to be loaded multiple times, as the data I'm dealing with appears to be unique, in that it's not "stepping into itself" and overwriting pointers, or anything.
    Am I going to have to create an instance of my class, via itself, to launch itself in the jvm manually - to keep the reference to dll in memory?
    Although that statement sounds terribly redundant... I believe it's accurate...
    1.) Create instance of class that's called by server-side, launch it under new jvm
    2.) Have orig class return to server-side as normal, and forward any new requests to the jvm-launched "self"; based on detection of class/jvm in memory...
    For being cross-platform "magical", Java sure makes it difficult to perform pretty basic tasks....

    Thanks for the great information jschell, this clears up alot. I'll play around with these new prospects and see if I can get this running properly.
    Also, let me define more what I'm actually doing.
    I'm using Railo, and a CFX "tag" to invoke a JAR. This Jar contains the JNI to execute a DLL's code. This dll's code is merely in place to perform some server tasks - mostly routine file maintenance, and checks to ensure normal operation. Some of this includes db queries. Yes this can be done in Java for the most part, but we plan to use the DLL exports later in a deployment scenario.
    So, "Did you mean it is loading the jar each time?", I do believe so. However, the instances appear to be different. If i were to create a thread within the JNI invoking class, which i have tried by the way, and create a global variable with some value, the second calling of the JAR file reports that it has not been defined yet on class initialization. Additionally, the thread I mentioned also halts, and does not exist within the second calling.
    Let me show some actual code...
    Test.cfm...
    <cfx_mytag Library="myLibrary.dll" task="function1">
    <cfscript>
    ... // do some stuff.
    </cfscript>If I were to alter that to:
    <cfx_mytag Library="myLibrary.dll" task="function1">
    <cfx_mytag Library="myLibrary.dll" task="function2">
    <cfscript>
    ... // do some stuff.
    </cfscript>I found that function2 in the same JAR, loaded via "cfx_mytag", reports inexistance of function1's execution - which registered a value into a global var.
    This is why I must assume that the JAR is being loaded independantly - each time. Correct me if wrong. Perhaps my terminology is off - the class within the jar file is multi-instanced, as far as I can tell. Or rather... Railo is creating mutliple instances of this class - and thus I lose my handle to my dll - every call... Seemingly at least.
    //Java...
    import com.allaire.cfx.*;
    public final class myClass implements CustomTag {
         private Request req;
         private Response res;
            public boolean igetresetoften;
         private native void gogoGadgetDLL();
         public myClass() {
        public void processRequest(Request request,Response response) throws Exception {
             this.req=request;this.res=response;
              if (!this.igetresetoften) {
                     igetresetoften=true;
                     res.write("yea... this is annoying");
                // in actual code - function1() assigns global var.
                // and function2() reports to response buffer the value of the global var , which is constantly false each run.
    }Notice the similarity to a servlet (request/response buffers). I've dealt with servlets, so I know that all requests are threaded.. but the global vars in a servlet are, in fact, ... global. Not in this case, it would seem.
    Thanks again, I'll let you know of my results, late tonight.
    Edited by: jSD7 on Nov 13, 2009 4:20 PM

  • Quick Guide to Server-side FMS?

    Are there any really simple examples of writing a hello world app on FMS that's accessed from Flex?  Something as basic as a Flex app poking a custom FMS app and getting a response from server-side ActionScript would be great.  I've looked all through the documentation and this seems to be lacking.
    Cheers

    Please have a look at Tutorials on FMSguru : http://fmsguru.com/tutorials.cfm - they are very helpful

  • Stateless - server side cookies

    Hello,
    I am having 2 problems in my stateless MVC BSP application.
    1. I am setting and getting table values using server side cookies. In page 1 - I am setting values in cookie. its not accessible in page 2 but they are accesible in page 3.
    2. When the application is closed by closing the IE, the server side cookies are in the server. How can I delete server side cookies if the application is closed? is it possible at all??
    3. I used delete server cookies - How can I delete cookies that were left undeleted due to the previous point - closing the application as such???
    I tried using session id as static and also sy-uname.....but the Id's stored in sscookie table have dynamic session ids.
    Please suggest..
    Thanks
    Thilothama

    hi
    good
    go through these links which give you idea about deleting the server side cookies.
    http://wp.netscape.com/newsref/std/cookie_spec.html
    http://curl.haxx.se/rfc/cookie_spec.html
    in sap->
    http://help.sap.com/saphelp_nw04s/helpdata/en/bd/4cd23a09313b37e10000000a11405a/content.htm
    thanks
    mrutyun

  • Changes in server side java file not reflecting in Client side java code?

    Hi friends,
    iam using eclipse IDE, JBoss server, SWING GUI and Oracle DB
    ( looks like : SWINGGUI (Client) <--> EJB's (serverside) <---oracle )
    my problem is , when i make change in server side bean file, that changes are not reflecting in GUI programs.
    (for ex: iam adding settr and getter for a field and using that in GUI program. but its not identifying that setter or getter).
    please tell me what should i do for every change done to server side program, that should reflect / available to GUI?

    my problem is , when i make change in server side bean file, that changes are not reflecting in GUI programs.
    (for ex: iam adding settr and getter for a field and using that in GUI program. but its not identifying that setter or getter).what do you mean it's not "identifying" the methods?
    you have to call those methods you know
    are you getting NoSuchMethodError?
    please tell me what should i do for every change done to server side program, that should reflect / available to GUI?you haven't posted any code or error messages that might help us debug

  • Can't get client and server to communicate

    hiya
    For some reason I can?t get server and client to exchange any messages ( server does receive a message from client only when I terminate the client process ).
    At first I thought that firewall was somehow preventing the two from communicating, but then I ran some server-client app ( which I copied from the book I?m learning from) and it worked perfectly. So problem must be my code, but I don?t see anything wrong with it.
    In the following code the client reads from console input and sends that to the server, which then echoes these data back to the client:
    CLIENT SIDE:
    import java.net.*;
    import java.io.*;
    import java.util.*;
    public class Main {
        static Socket s;
        static String message, response;
        public static void main( String[] args ) {
                  try{
                      send( 2000 );
                  catch( Exception e { e.printStackTrace(); }
        static void send( int port ) throws IOException {
                InetAddress ia = InetAddress.getLocalHost();
                s = new Socket( ia, port );
                OutputStreamWriter ow = new OutputStreamWriter(
                        s.getOutputStream(), "UTF8" );
                BufferedWriter bw = new BufferedWriter ( ow ) ;
                InputStreamReader ir  = new InputStreamReader(
                        s.getInputStream(), "UTF8" );
                BufferedReader br = new BufferedReader ( ir );
                InputStreamReader console = new InputStreamReader (
                        System.in );
                BufferedReader readConsole = new BufferedReader (
                        console );
                do
                    message = readConsole.readLine();
                    bw.write( message );
                    bw.flush();
                    System.out.println( "waiting for a response" );
                    response = br.readLine();
                    System.out.print( " This was sent by server:" );
                    System.out.println ( response );
                } while  (  !message.equals( "Stop" ) );
                s.close();
    SERVER SIDE:
    import java.net.*;
    import java.io.*;
    import java.util.*;
    public class Main {
        public static void main( String[] args )  {
            try{
                  Server.Init();
                  Server.handleClient();
            catch( Exception e ){ e.printStackTrace(); }
    class Server {
        static int port = 2000;
        static ServerSocket servs;
        static Socket s;
        static  void Init() throws IOException {
            servs = new ServerSocket( port );
        static void handleClient() throws IOException {
            do{
                     Server.connect();
            } while( true );
       static void connect() throws IOException {
              s = servs.accept();
              InputStream is = s.getInputStream();
              InputStreamReader isr = new InputStreamReader(is);
              BufferedReader bf = new BufferedReader(isr);
              OutputStream os   = s.getOutputStream();
              OutputStreamWriter osw = new OutputStreamWriter(os);
              BufferedWriter bfw  = new BufferedWriter(osw);
              String messages;
              System.out.println("reading first message");
              messages = bf.readLine();
              System.out.println("first message read");
              while ( ! messages.equals( "Stop" ) ) {
                  bfw.write ( "message received" );
                  bfw.flush();
                  System.out.println( messages );
                  messages = bf.readLine();
              s.close();
       } any help would be appreciated
    thank you

    I assumed that when client reads from console, the newline character is also copied into a string returned by readline(). I guess that applies only to read() methods, but not readline()?!
    EDIT -I noticed that while now server does get the message and also sends it back to client, it doesn't itself display the message, even if I use flush(). Why is that?
              while ( ! messages.equals("Stop") ){
                  bfw.write ( "message received" );
                  bfw.newLine();
                  bfw.flush();
                  System.out.println( messages ); // this doesn't get written to the
                                                                    console
                  System.out.flush();
                  messages = bf.readLine();
              }EDIT 2 - Nevermind. All works as it should!
    thank you kindly for your help

Maybe you are looking for