File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes GWT and the fly likes Communication to server--RPC or HTTP Client classes? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "Communication to server--RPC or HTTP Client classes?" Watch "Communication to server--RPC or HTTP Client classes?" New topic

Communication to server--RPC or HTTP Client classes?

Benjamin Weaver
Ranch Hand

Joined: Apr 08, 2003
Posts: 161
I would like to incorporate a GWT front-end into a Spring application. This Spring application will have several different kinds of views. GWT will be only one of them.

Given this requirement, it would be nice to decouple the GWT from the server-side code. The GWT Http Request Classes in look like an attractive alternative to RPC.

I am a GWT newbie. Perhaps I am not understanding what RPC does. But I ask, for the sake of drawing out the issue,

Why would one ever want to use GWT RPC? Why would not one want always want to use the Http Client classes, in order to decouple server-side code from client-code, with plain Java controller code on the server not wedded to GWT specifics?

or, if the RPC code is necessary, what would be the best way to encapsulate it in this multiple view-style Spring application? Put it into a "GWTController"?

Any suggestions or comments are welcome!

Thanks in advance.

Benjamin Weaver
Ranch Hand

Joined: Apr 08, 2003
Posts: 161
...or, continuing my second question, if RCP is necessary, why not redirect from Spring Dispatcher Servlet--not to a Controller, but to another servlet, a GWTServlet?

Prabakar Kalivaradan

Joined: Dec 12, 2011
Posts: 20


What it means to implement GWT RPC?

Write a servlet on server side. Everything works like a magic. This is what a GWT RPC gives you. All your client UI code does is get java objects from the GWT Servlet and work with java objects. You wouldn't need to handle HTTP requests, parsing the data or json format or anything else. Your client code remains a pure java code working with java objects alone.

GWT Servlet takes care of translating java objects which are transported to client side, as http requests automatically. So, you need not bother.

Now then, to plugin into spring; yes it is like as you mentioned. For certain views(url patterns), redirect the requests in spring to gwt guy. If you look at how to implement your gwt servlet for RPC, you will know that, the servlet is configured to serve a paritular url pattern.

Good luck!

Benjamin Weaver
Ranch Hand

Joined: Apr 08, 2003
Posts: 161
Thanks, Prabakar, you remind me of the benefits of using a servlet. As you say a servlet allows you to work with Java objects and I don't have to worry about httpRequests, formatting, Jason, etc.

And thanks for the confirmation about how to use GWT in Spring. I will approach the problem with more confidence.
I agree. Here's the link:
subject: Communication to server--RPC or HTTP Client classes?
It's not a secret anymore!