Take the 2-minute tour ×

I'm new to GWT. I'm using the eclipse to create a simple application. After understood the basics like, how to run the project in development mode and production mode but one thing i'm unable to understand. In google they given a sample build project, when i finished with that i seen one more tutorial called RPC in GWT. Here they changed the previous code and implemented the new one. In GWT everything is converted into the javascript but when we are using the RPC, then RPC(server) code will be in the java bytes format at server. My question is why we have to implement the RPC? What's the need to use RPC?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

Well imagine that you want to call an operation that is implemented on the server side, for example login a user.

There is a database of registered users on the sever. The clinet (javascript code in browser) must send the name and password of the user to server. The server (java code) then contacts the database and authenticates the user and returns a true or false back to client. This way you have romotely called an operation (the login procedure) on the server from client, and got a response back. Hence the name RPC.

The key here is to understand client side and server side. On the client side you have javascript, but with java script you cannt access a database. Additionally you don't have the databse of all registered users on every client (browser). So you have the server side that contains the databse and also the java code to connect to this database. Each client just tell the server to do the corresponding operation via RPC and gets the result back.

share|improve this answer
So we can say RPC also kind of AJAX works?? –  Mayilarun Sep 13 '11 at 12:30
Yes exactly. Actually GWT is also an AJAX framework. However you have the ease for writing code that runs on client browser using familiar java, with all conveniances of java, like type safty. That's why you use an Async Interface for your service. The GWT then translates this java to java script. That is behind the Async RPC call there is an XmlHttpRequest. –  zardosht Sep 14 '11 at 12:13

The need to use RPC is to let your Client communicate with the server via asynchronous calls. RPC abstracts this call in a way so that calling a method on a server is analog to calling a method on a normal object. So, calling a local method and calling a "remote" method becomes basically the same.

(Of course, you could also write client code which never calls a server.)

share|improve this answer

Check out this link...will ans your Q. UML diagram will make it more clear to u https://developers.google.com/web-toolkit/doc/latest/DevGuideServerCommunication#DevGuideServerSide

share|improve this answer

Your Answer


