[java ee programming] java socket question
Hello, I'm writing a c++ server and a java client that connects to it. The client connects to the server (TCP), sends a message and gets a echo reply every time, so the two can speak freely. But i'm puzzeled because I want the server to send data to the client when an event happens (I push a button on the server). When te event occurs the server sends the string, but the client does't receive it until it does a send/receive reply when it receives both the event string and the echo string. I implemented socket read into a separeted thread: public class Cititor implements Runnable{ private Socket skt ; private BufferedReader in; private PrintWriter out ; private Boolean connected ; private javax.swing.JTextArea afis; public Cititor(Socket skt, BufferedReader in, PrintWriter out, Boolean connected, JTextArea afis) { this.skt = skt; this.in = in; this.out = out; this.connected = connected; this.afis = afis; } public void run(){ System.out.println(să citim mesajele + connected); String inputLine = new String(), outputLine; do { try { Thread.sleep(100); if (connected) { try { //out.print( ); out.flush(); inputLine = in.readLine(); if (!inputLine.equals( )) afis.append(inputLine + \n); System.out.println(inputLine); } catch (IOException e) { System.err.println(Excepție citire din socket!); } } } catch (InterruptedException ex) { Logger.getLogger(Chat.class.getName()).log (Level.SEVERE, null, ex); } }while (inputLine.equals(pa!) == false) ; } In the main class init method I have this: myCititor = new Cititor(skt,in,out,connected,afisare); Thread t = new Thread ( myCititor); t.start(); And to send messages to the server I push a button: private void trimiteActionPerformed(java.awt.event.ActionEvent evt) { if (connected) out.println(textTrimite.getText()); else System.out.println(No connection); } The server uses a switch statement with FD_READ,FD_ACCEPT and FD_CLOSE (processing WSAGETSELECT event - WsAsync), and sends when a button is pushed (I'm using windows events button clicked). The trying to make the server capable of informing the client when an event occurs. The server is used for monitoring certain activities. But the client does't receive unless it sends and waits for a reply. What am I doing wrong? Regards, -- stan ioan-eugen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Java EE (J2EE) Programming with Passion! group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en -~--~~~~--~~--~--~---
[java ee programming] Re: java socket question
It is not always possible for servers to report anything to the clients, unless ofcourse, the client is connected to the server. The only way that could happen is if the client doubles as a server too, that way, it gets notifications from other clients. Or maybe I didn't get your question correctly - Again we'd need the C++ code to see where you're going wrong. -- Evans - Original Message - From: ioan-eugen stan stan.ieu...@gmail.com To: Java EE (J2EE) Programming with Passion! java-ee-j2ee-programming-with-passion@googlegroups.com Sent: Friday, September 11, 2009 10:13 AM Subject: [java ee programming] java socket question Hello, I'm writing a c++ server and a java client that connects to it. The client connects to the server (TCP), sends a message and gets a echo reply every time, so the two can speak freely. But i'm puzzeled because I want the server to send data to the client when an event happens (I push a button on the server). When te event occurs the server sends the string, but the client does't receive it until it does a send/receive reply when it receives both the event string and the echo string. I implemented socket read into a separeted thread: public class Cititor implements Runnable{ private Socket skt ; private BufferedReader in; private PrintWriter out ; private Boolean connected ; private javax.swing.JTextArea afis; public Cititor(Socket skt, BufferedReader in, PrintWriter out, Boolean connected, JTextArea afis) { this.skt = skt; this.in = in; this.out = out; this.connected = connected; this.afis = afis; } public void run(){ System.out.println(să citim mesajele + connected); String inputLine = new String(), outputLine; do { try { Thread.sleep(100); if (connected) { try { //out.print( ); out.flush(); inputLine = in.readLine(); if (!inputLine.equals( )) afis.append(inputLine + \n); System.out.println(inputLine); } catch (IOException e) { System.err.println(Excepție citire din socket!); } } } catch (InterruptedException ex) { Logger.getLogger(Chat.class.getName()).log (Level.SEVERE, null, ex); } }while (inputLine.equals(pa!) == false) ; } In the main class init method I have this: myCititor = new Cititor(skt,in,out,connected,afisare); Thread t = new Thread ( myCititor); t.start(); And to send messages to the server I push a button: private void trimiteActionPerformed(java.awt.event.ActionEvent evt) { if (connected) out.println(textTrimite.getText()); else System.out.println(No connection); } The server uses a switch statement with FD_READ,FD_ACCEPT and FD_CLOSE (processing WSAGETSELECT event - WsAsync), and sends when a button is pushed (I'm using windows events button clicked). The trying to make the server capable of informing the client when an event occurs. The server is used for monitoring certain activities. But the client does't receive unless it sends and waits for a reply. What am I doing wrong? Regards, -- stan ioan-eugen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Java EE (J2EE) Programming with Passion! group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en -~--~~~~--~~--~--~---
[java ee programming] class ActionError
Hello, I'm new programing struts. Thanks in advance to undertand my poor knowledge. I'm trying to run struts-submit-solution project but i get the following error: C:\strutsbasics\samples\struts-submit-exercise4-solution\src\java\submit\SubmitForm.java:80: cannot find symbol symbol : class ActionError location: class submit.SubmitForm errors.add(Last Name, new ActionError(error.lastName)); Thanks, Daniel ¡Obtén la mejor experiencia en la web! Descarga gratis el nuevo Internet Explorer 8. http://downloads.yahoo.com/ieak8/?l=e1 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Java EE (J2EE) Programming with Passion! group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en -~--~~~~--~~--~--~---
[java ee programming] Re: Populating the E xample Database needs password file
Any other choice is getting Textpad as well. Regards, Rafael. From: Alin Dumitrescu dorud...@gmail.com To: j2ee passion java-ee-j2ee-programming-with-passion@googlegroups.com Sent: Thursday, September 10, 2009 9:47:21 AM Subject: [java ee programming] Re: Populating the Example Database needs password file For development purposes, if you don’t want to use the NetBeans to edit your files(.java or .properties or .xml or dotwhatever) try to use the Notepad++, it knows a lot of file types, you’ll love it. http://notepad-plus.sourceforge.net/uk/site.htm Happy coding! From:java-ee-j2ee-programming-with-passion@googlegroups.com [mailto:java-ee-j2ee-programming-with-pass...@googlegroups.com] On Behalf Of peeter brunch Sent: September-10-09 3:22 AM To: migat...@gmail.com; j2ee passion Subject: [java ee programming] Re: Populating the Example Database needs password file Hi everyone, I used notepad to open the property file and rename the file. Now all the problems have gone. Thanks for the help. Cheers From: peeterbru...@hotmail.com To: migat...@gmail.com; java-ee-j2ee-programming-with-passion@googlegroups.com Subject: RE: [java ee programming] Re: Populating the Example Database needs password file Date: Thu, 10 Sep 2009 04:45:04 + Thanks for the clue. I have edited my build.properties file to include the passwordfile definition. But the build returned with the same failure message javaee.server.passwordfile not specified. My changes to the build.properties file are highlighted as below: # Set the property javaee.home, using the path to your # GlassFish installation. # C:/Program Files/glassfish-v3 is the GlassFish v3 default installation # path on Windows. # javaee.home=C:/Program Files (x86)/sges-v3-prelude # Set the property javaee.tutorial.home to the location where you # installed the Java EE Tutorial bundle. # javaee.tutorial.home=E:/techdoc/J2ee/javaee-5-doc-tutorial-1.0_05/javaeetutorial5 # machine name (or the IP address) where the applications will be deployed. javaee.server.name=localhost # port number where GlassFish applications are accessed by users javaee.server.port=8080 # port number where the Admin Console of GlassFish is available javaee.adminserver.port=4848 # Uncomment the property javaee.server.username, # and replace the administrator username of the app-server javaee.server.username=admin # Uncomment the property javaee.server.passwordfile, # and replace the followingline to point to a file that # contains the admin password for your app-server. # The file should contain the password in the following line: # # AS_ADMIN_PASSWORD=adminadmin # # Notice that the password is adminadmin since this is # the default password used by GlassFish. # javaee.server.passwordfile=${javaee.tutorial.home}/examples/common/admin-password.txt appserver.instance=server # Uncomment and set this property to the location of the browser you # choose to launch when an application is deployed. # On Windows and Mac OS X the OS default browser is used. #default.browser=/Applications/Firefox.app/Contents/MacOS/firefox-bin # Database vendor property for db tasks # JavaDB is the default database vendor. See the settings in javadb.properties db.vendor=javadb # Digital certificate properties for mutual authentication keystore=${javaee.tutorial.home}/examples/jaxws/simpleclient-cert/support/client_keystore.jks truststore=${javaee.home}/domains/domain1/config/cacerts.jks keystore.password=changeit truststore.password=changeit Is anything wrong with my changes? I use MS WORD to open the sample file and edit/save the changes(since I do not have the right software to open the sample or properties type file type in Window Vista). I renamed the file with Properties extension after saving the file. Would it be possible that Word would corrupt the properties file or its internal format so Build process is unable to read the file properly.The size of the original sample file is 2KB but the edited file is 13KB. I am attaching my property file for perusing. Can anyone whose has successfully populating the Bookstore1 example database send me their build.propertiies file so I can use it to build my database? Thanks in advance. P.S: I always try to send mail without an attachment. But I cannot cut and paste the screen shots from Dos command prompt terminal windows. Pls advise if there is any proper method to cut and paste text content from Dos. Sorry for the inconvenience if that this might cause. Date: Tue, 8 Sep 2009 20:36:58 -0700 Subject: [java ee programming] Re: Populating the Example Database needs password file From: migat...@gmail.com To: java-ee-j2ee-programming-with-passion@googlegroups.com On 8 sep, 11:41, peeter brunch peeterbru...@hotmail.com wrote: During the build of Example Database for Bookstore1 project, the build process
[java ee programming] Re: class ActionError
Looks like struts.jar is not available on the classpath. You need it to run your code. - Evans http://valashiya.blogspot.com - Original Message - From: daniel vargas danielseb...@yahoo.com To: java-ee-j2ee-programming-with-passion@googlegroups.com Sent: Friday, September 11, 2009 1:32 PM Subject: [java ee programming] class ActionError Hello, I'm new programing struts. Thanks in advance to undertand my poor knowledge. I'm trying to run struts-submit-solution project but i get the following error: C:\strutsbasics\samples\struts-submit-exercise4-solution\src\java\submit\SubmitForm.java:80: cannot find symbol symbol : class ActionError location: class submit.SubmitForm errors.add(Last Name, new ActionError(error.lastName)); Thanks, Daniel ¡Obtén la mejor experiencia en la web! Descarga gratis el nuevo Internet Explorer 8. http://downloads.yahoo.com/ieak8/?l=e1 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Java EE (J2EE) Programming with Passion! group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en -~--~~~~--~~--~--~---
[java ee programming] Re: Lab 4016
Hi, Solved, The database username and password need to be app in both cases and the database name sample. Regards Alfredo On Sep 10, 6:08 pm, Alfredo Torres alfredoluis.tor...@gmail.com wrote: Hi, I set up the database an create the book table but when i try tu run the Web my browser go to http://www.fastbrowsersearch.com/results/results.aspx?q=http://localh...{52AD233E-F9A1-C526-C4A9-09AD445803DB} Anuone know the solution for this? Thanks in advance --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Java EE (J2EE) Programming with Passion! group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en -~--~~~~--~~--~--~---
[java ee programming] Re: class ActionError
I think you are using Netbeans 6.7.1 that comes with struts 1.3.8 version , for running this samples I think you need struts 1.2.x download it from (http://archive.apache.org/dist/struts/binaries/struts-1.2.9-bin.zip) , then remove struts 1.38 from the project and add the jars that comes with struts-1.2.9-bin distribution y try to execute the sample again. Regards Julian Rivera Pineda Java Helper Rover From: daniel vargas danielseb...@yahoo.com To: java-ee-j2ee-programming-with-passion@googlegroups.com Sent: Friday, 11 September, 2009 6:32:20 Subject: [java ee programming] class ActionError Hello, I'm new programing struts. Thanks in advance to undertand my poor knowledge. I'm trying to run struts-submit-solution project but i get the following error: C:\strutsbasics\samples\struts-submit-exercise4-solution\src\java\submit\SubmitForm.java:80: cannot find symbol symbol : class ActionError location: class submit.SubmitForm errors.add(Last Name, new ActionError(error.lastName)); Thanks, Daniel ¡Obtén la mejor experiencia en la web! Descarga gratis el nuevo Internet Explorer 8. http://downloads.yahoo.com/ieak8/?l=e1 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Java EE (J2EE) Programming with Passion! group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en -~--~~~~--~~--~--~---
[java ee programming] LAB-4016 Build and run bookstore4-jndi sample application
Hi, I follow the steps to create the jdbc resource and morify the derby pool in the admin console in Glassfish 3.0 prelude. But when i try to run the sample Web bookstore4-jndi i receive this exception: java.lang.NoClassDefFoundError: org/apache/derby/client/am/ FailedProperties40 Where is supose to be that class?? or i have to addd something to the classpath? Thanks in advance --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Java EE (J2EE) Programming with Passion! group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en -~--~~~~--~~--~--~---
[java ee programming] Re: LAB-4016 Build and run bookstore4-jndi sample application
Maybe this thread solves your question: http://groups.google.com/group/java-ee-j2ee-programming-with-passion/tree/browse_frm/month/2007-07/86b9609fadef2ce9?rnum=31_done=%2Fgroup%2Fjava-ee-j2ee-programming-with-passion%2Fbrowse_frm%2Fmonth%2F2007-07%3F#doc_811dc96b333000dc Julian Rivera Pineda Java Helper Rover From: Alfredo Torres alfredoluis.tor...@gmail.com To: Java EE (J2EE) Programming with Passion! java-ee-j2ee-programming-with-passion@googlegroups.com Sent: Friday, 11 September, 2009 9:41:04 Subject: [java ee programming] LAB-4016 Build and run bookstore4-jndi sample application Hi, I follow the steps to create the jdbc resource and morify the derby pool in the admin console in Glassfish 3.0 prelude. But when i try to run the sample Web bookstore4-jndi i receive this exception: java.lang.NoClassDefFoundError: org/apache/derby/client/am/ FailedProperties40 Where is supose to be that class?? or i have to addd something to the classpath? Thanks in advance --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Java EE (J2EE) Programming with Passion! group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en -~--~~~~--~~--~--~---
[java ee programming] Re: Populating the E xample Database needs password file
Hi, as we're talking about: I like PSPad http://www.pspad.com;. It is really freeware (not shareware or the community release with less functions than the commercial one or so) with all functions, it is light ... Regards, mihai Rafael Padron a écrit : Any other choice is getting Textpad as well. Regards, Rafael. *From:* Alin Dumitrescu dorud...@gmail.com *To:* j2ee passion java-ee-j2ee-programming-with-passion@googlegroups.com *Sent:* Thursday, September 10, 2009 9:47:21 AM *Subject:* [java ee programming] Re: Populating the Example Database needs password file For development purposes, if you don’t want to use the NetBeans to edit your files(.java or .properties or .xml or dotwhatever) try to use the Notepad++, it knows a lot of file types, you’ll love it. http://notepad-plus.sourceforge.net/uk/site.htm Happy coding! *From:* java-ee-j2ee-programming-with-passion@googlegroups.com [mailto:java-ee-j2ee-programming-with-pass...@googlegroups.com] *On Behalf Of *peeter brunch *Sent:* September-10-09 3:22 AM *To:* migat...@gmail.com; j2ee passion *Subject:* [java ee programming] Re: Populating the Example Database needs password file Hi everyone, I used notepad to open the property file and rename the file. Now all the problems have gone. Thanks for the help. Cheers From: peeterbru...@hotmail.com To: migat...@gmail.com; java-ee-j2ee-programming-with-passion@googlegroups.com Subject: RE: [java ee programming] Re: Populating the Example Database needs password file Date: Thu, 10 Sep 2009 04:45:04 + Thanks for the clue. I have edited my build.properties file to include the passwordfile definition. But the build returned with the same failure message *javaee.server.passwordfile not specified.** * My changes to the build.properties file are highlighted as below: # Set the property javaee.home, using the path to your # GlassFish installation. # C:/Program Files/glassfish-v3 is the GlassFish v3 default installation # path on Windows. # javaee.home=C:/Program Files (x86)/sges-v3-prelude # Set the property javaee.tutorial.home to the location where you # installed the Java EE Tutorial bundle. # javaee.tutorial.home=E:/techdoc/J2ee/javaee-5-doc-tutorial-1.0_05/javaeetutorial5 # machine name (or the IP address) where the applications will be deployed. javaee.server.name=localhost # port number where GlassFish applications are accessed by users javaee.server.port=8080 # port number where the Admin Console of GlassFish is available javaee.adminserver.port=4848 # Uncomment the property javaee.server.username, # and replace the administrator username of the app-server javaee.server.username=admin # Uncomment the property javaee.server.passwordfile, # and replace the following line to point to a file that # contains the admin password for your app-server. # The file should contain the password in the following line: # # AS_ADMIN_PASSWORD=adminadmin # # Notice that the password is adminadmin since this is # the default password used by GlassFish. # javaee.server.passwordfile=${javaee.tutorial.home}/examples/common/admin-password.txt appserver.instance=server # Uncomment and set this property to the location of the browser you # choose to launch when an application is deployed. # On Windows and Mac OS X the OS default browser is used. #default.browser=/Applications/Firefox.app/Contents/MacOS/firefox-bin # Database vendor property for db tasks # JavaDB is the default database vendor. See the settings in javadb.properties db.vendor=javadb # Digital certificate properties for mutual authentication keystore=${javaee.tutorial.home}/examples/jaxws/simpleclient-cert/support/client_keystore.jks truststore=${javaee.home}/domains/domain1/config/cacerts.jks keystore.password=changeit truststore.password=changeit Is anything wrong with my changes? I use MS WORD to open the sample file and edit/save the changes(since I do not have the right software to open the sample or properties type file type in Window Vista). I renamed the file with Properties extension after saving the file. Would it be possible that Word would corrupt the properties file or its internal format so Build process is unable to read the file properly.The size of the original sample file is 2KB but the edited file is 13KB. I am attaching my property file for perusing. Can anyone whose has successfully populating the Bookstore1 example database send me their build.propertiies file so I can use it to build my database? Thanks in advance. P.S: I always try to send mail without an attachment. But I cannot cut and paste the screen shots from Dos command prompt
[java ee programming] Re: Applet lesson
Hi, I found a really nice and perfect tutorial for beginners like me http://java.sun.com/docs/books/tutorial/deployment/applet/index.html It is a great tutorial Hope this help someone Regards Alfredo On Sep 11, 1:49 pm, Alfredo Torres alfredoluis.tor...@gmail.com wrote: Hi, In the applets lesson, The las one in Web Core Technologies: Servlet and JSP just have one link NetBeans IDE Applet Tutorial and is broken, so i found this tutorial in replacement. http://www.netbeans.org/kb/61/web/applets.html Hope this help others Regards Alfredo -- Saludos Alfredo Torres Hab.+58 212 9446304 Cel. +58 416 6118599 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Java EE (J2EE) Programming with Passion! group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en -~--~~~~--~~--~--~---