Iam completely new gwt-rpc. I have read few documentation, but not clear at one point. Iam going to describe it.
My client side build is going to implement gwt-rpc to call the server side servlets to access the data. So, do i need to implement server side RPC too?
Means, will client side gwt-rpc will communicate with server side RPC, and that server side rpc will communicate with the servlets? or directly client side gwt-rpc will communicate with servlets?
Thanks
Yes, you need to implement server side RPC too.
You have to build a Servlet in your server side, which must extends the class com.google.gwt.user.server.rpc.RemoteServiceServlet and implements your RPC interface. You have to register this new Servlet which you have implemented in your web.xml. For example.
Your new Servlet:
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
public class MyServerSideRPC extends RemoteServiceServlet implements MyRpcInterface{
@Override
public String myRpcMethod(....) {
//Do RPC method work
}
}
Your RPC interface which is implemented by your new Servlet
@RemoteServiceRelativePath("service/myrpcpath")
public interface MyRpcInterface extends RemoteService{
public String myRpcMethod(....);
}
And in your web.xml on your server side, register the servlet you have created,
<servlet>
<servlet-name>MyServerSideRPC</servlet-name>
<servlet-class>.....MyServerSideRPC</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServerSideRPC</servlet-name>
<url-pattern>/gwtrpc/service/myrpcpath</url-pattern>
</servlet-mapping>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.