accepting posts from non-GWT pages

1 view
Skip to first unread message

boscomonkey

unread,
Dec 13, 2006, 4:59:06 PM12/13/06
to Google Web Toolkit
In our GWT app, we have a login dialog box that pops up to handle fresh
users or users whose sessions have timed out. Now we wish to accept
username/password POSTs from our static web site or even affiliate web
sites. What are some approaches for handling POSTs from outside the GWT
app?

It seems that one simple approach is to write a standard servlet that
implements doPost, place it in our GWT app's server package space, and
if users authenticate properly, redirect to our GWT app's URL. In this
case, do I have to map this servlet in our MODULE.gwt.xml? What's the
URL to this servlet?

boscomonkey

unread,
Dec 14, 2006, 6:18:37 PM12/14/06
to Google Web Toolkit
I figured out the answers to my own question. The way to handle non-GWT
POSTs in GWT servlet is to:
* Override the service(...) method. If your servlet inherits from
GWT's RemoteServiceServlet, you can't override doPost as
RemoteServiceServlet has marked it final.
* Figure out some way to distinguish a GWT POST from a non-GWT
POST. The easiest way is to add a hidden field (i.e., <input
type="hidden" name=NON_GWT value="true" />) and check for that
parameter value in the service(...) method. If that parameter
isn't there, then call super.service(...) so that GWT calls can
go through.
* Declared the servlet in MODULE.gwt.xml like any other servlet
(GWT or not).

Since I use Instantiation's GWT Designer, it automatically generates
the service's Async interface java file, implementation java file, and
servlet entry in the MODULE.gwt.xml file. Thus all I do is add the
service(...) method in the implementation file.

Cheers.

jon

unread,
Dec 15, 2006, 1:53:09 AM12/15/06
to Google Web Toolkit
It's seems to me that this unnecessarily couples the logon
functionality to a particular GWT service implementation. Wouldn't it
be better to use a separate servlet for that purpose and simply have
that redirect to the GWT module upon successful logon?

Reply all
Reply to author
Forward
0 new messages