my dog learned polymorphism*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: 101 Networking and message handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX: 101 Networking and message handling" Watch "NX: 101 Networking and message handling" New topic
Author

NX: 101 Networking and message handling

Bill Robertson
Ranch Hand

Joined: Mar 21, 2003
Posts: 234
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?
Bill Robertson
Ranch Hand

Joined: Mar 21, 2003
Posts: 234
Andrew could you help on this?
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
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
Bill Robertson
Ranch Hand

Joined: Mar 21, 2003
Posts: 234
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.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
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).
Bill Robertson
Ranch Hand

Joined: Mar 21, 2003
Posts: 234
thanks jim!!!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: NX: 101 Networking and message handling
 
Similar Threads
Command Line Argument - Mode Flag
Opinion on showing stack trace in GUI
RequestDispatcher's forward method does not work.
Do you guys handle the scenario of RMI server down in GUI side?
Database location (a different approach?)