Advertisement

10.12.2008 at 12:50PM PDT, ID: 23808006 | Points: 500
[x]
Attachment Details

Interfacing a servlet with GWT (google web toolkit)

Asked by DJ_AM_Juicebox in J2EE, Java Servlets, JavaScript Frameworks

Hi,

I've been using GWT(google web toolkit) for a few days and it lets you map client requests to a Servlet function. It handles serializing the message passing I guess, so you end up with something like:

    // clientside
    MyServletInterface.java
         myServletFunction(String s, Integer i);

    // Server side
    MyServlet.java
         myServletFunction(String s, Integer i)
         {
              // whatever you want the servlet to do server-side.
         }


So that is great. Now there's this chat protocol called Cometd and it's already setup using continuations and looks great. I'd like to use it with GWT but they've got their servlet implementation setup differently than I'm used to seeing with GWT (I guess actuallly this is the standard way of writing a servlet) they have this:

    ContinuationCometdServlet.java
    void service(HttpServletRequest request, HttpServletResponse response)
    {
         // handle client request
    }

The source of that class is here (signatures are a little different but same idea I guess):

    http://jetty.mortbay.org/jetty/jetty-7/xref/org/mortbay/cometd/continuation/ContinuationCometdServlet.html


now I'm not sure if GWT can interface with that at all, because GWT wants to let you define your own servlet signature where you're passing along any serializable objects, but here they're expecting the raw request and response objects.

I can get the raw request and service objects from a servlet function in GWT, I'm wondering if I can cheat somehow and just pass it through like:

    MyServletCheatFunction(MyParameters)
    {
         // Just call the normal servlet function:
         service(getRequest(), getResponse());
    }

    void service(HttpServletRequest request, HttpServletResponse response)
    {
        // do what they normally do
    }

Yeah that looks pretty bad but I'm wondering if anyone has any ideas as to how I could go about doing something like this?

ThanksStart Free Trial
 
Loading Advertisement...
 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628