Skip to content

Instantly share code, notes, and snippets.

@javajosh
Created April 23, 2009 01:54
Show Gist options
  • Save javajosh/100232 to your computer and use it in GitHub Desktop.
Save javajosh/100232 to your computer and use it in GitHub Desktop.
package com.javajosh.bender.server;
import com.javajosh.bender.client.GreetingService;
import com.javajosh.bender.client.GreetingServiceAsync;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/**
* The server side implementation of the RPC service.
*/
@SuppressWarnings("serial")
public class GreetingServiceImpl extends RemoteServiceServlet implements
GreetingService {
//Logger.getLogger(GreetingService.class.getName());
public String greetServer(String input) {
String serverInfo = getServletContext().getServerInfo();
String userAgent = getThreadLocalRequest().getHeader("User-Agent");
return "Hello, " + input + "!<br><br>I am running " + serverInfo
+ ".<br><br>It looks like you are using:<br>" + userAgent;
}
public void callService() {
final GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
String textToServer ="HELLO";
greetingService.greetServer(textToServer,
new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
System.out.println("problem");
}
public void onSuccess(String result) {
System.out.println(result);
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment