Re: GWT 2 Servlet

2011-10-03 Thread Sudhakar Abraham
Build the RequestBuilder object in Client side. Implement the
RequestCallback interface in client side code, override the
onResponseReceived(), onError() method. Call the send() method in
RequestBuilder class, requestBuilder object call the service method in
servlet. Try the below code to talk to servlet.

//client side code

public class RequestBuilderTest implements RequestCallback
{
private RequestBuilder rb;
public RequestBuilderTest()
{
rb = new 
RequestBuilder(RequestBuilder.POST,Your_servlet_name);
rb.setCallback(this);
Button send = new Button(Mail);
   send.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
try
{
rb.send();
}
catch(RequestException e)
{

}

}
  });
RootLayoutPanel.get().add(send);
}

@Override
public void onError(Request request, Throwable exception)
{
Window.alert(Error received from servlet);
}
@Override
public void onResponseReceived(Request request, Response response)
{
Window.alert(Response received from servlet);
}

}

//server side code

public class TestServlet extends HttpServlet
 {
   private static final long serialVersionUID = 1L;
   public void doPost(HttpServletRequest req, HttpServletResponse
resp)
   {
 try
{
   int port =req.getRemotePort();
   System.out.println(port :+port);
}
 catch (AddressException e1)
{
  e1.printStackTrace();
}
}


// To edit web.xml in War directory

?xml version=1.0 encoding=UTF-8?
!DOCTYPE web-app
PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN
http://java.sun.com/dtd/web-app_2_3.dtd;
web-app
   !-- Servlets --
 servlet
 servlet-nameSampleServlet/servlet-name
 servlet-classcom.tan.server.TestServlet/servlet-class
/servlet
servlet-mapping
 servlet-nameSampleServlet/servlet-name
 url-pattern/Your_servlet_name/url-pattern
/servlet-mapping
  !-- Default page to serve --
 welcome-file-list
welcome-fileSampleGAE.html/welcome-file
 /welcome-file-list
/web-app

S. Abraham
www.DataStoreGwt.com
Persist objects directly in GAE

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



GWT 2 Servlet

2011-09-30 Thread Navindian
Hi foks,

I wish to have GWT component talk to a Servlet. Any quick suggestion?

Thanks
Naveen Gayar

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: GWT 2 Servlet

2011-09-30 Thread Juan Pablo Gardella
See
http://code.google.com/intl/es-419/webtoolkit/doc/latest/DevGuideServerCommunication.html

2011/9/30 Navindian navind...@gmail.com

 Hi foks,

 I wish to have GWT component talk to a Servlet. Any quick suggestion?

 Thanks
 Naveen Gayar

 --
 You received this message because you are subscribed to the Google Groups
 Google Web Toolkit group.
 To post to this group, send email to google-web-toolkit@googlegroups.com.
 To unsubscribe from this group, send email to
 google-web-toolkit+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/google-web-toolkit?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.