This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
If you are in network mode and your sever is running on another computer. And you get an exception in your server code so you send a message to the user via a JDialog/JOptionPane, will the end user using the gui front end on another computer get the pop-up message or is it lost on the server computer? Am I making sense? Because I know if you print the details of an exception it will not show up on the client side, given you handled and printed the details from the server side, but I am not sure about dialog messages. How does it come through to the gui client?
If you're using RMI and you've got a class running on the server which implements the Remote interface, then when a client does Naming.lookup() or whatever and gets aremote reference to your server instance, they can call methods. If the client calls update() and the server throws a SecurityException(), the client will see a SecurityException thrown from the update() method it called on the remote proxy. Behind the scenes, RMI has serialized the exception thrown on the server and passed it to the client, making it look like it was thrown form the client. (All exceptions implement Serializable, so this is possible). If you use sockets rather than RMI, you will have to send some sort of signal through the socket to tell the client that an exception needs to be thrown. The simplest wayt to do this is probably to use an ObjectOutputStream to serialize the exception and send it through the socket, much like RMI does (except you ahve to code it yourself). Or you could devise some other communications protocol which may be faster but require even more coding on your part; it's up to you.
"I'm not back." - Bill Harding, Twister
Joined: Mar 21, 2003
Jim, I am using RMI. I was just wondering if a dialog message box would appear on the client side even though the call to the dialog was made on the the server side. Given of course the server and client resided on two different machines.
Joined: Jan 30, 2000
Nope. All communication between client & server will be through the methods of Remote interfaces. Data are passed as method parameters, return values, or exceptions. Any other side effects of a method call occur only on the machine that hosts the implementation of the remote object (ther server).