How to tell if a servlet is running in hosted mode?

109 views
Skip to first unread message

Nano Elefant

unread,
Nov 15, 2012, 4:13:27 PM11/15/12
to google-we...@googlegroups.com
Hello,
Is there a reliable way to determine if a servlet is running in hosted mode or on a production server (for example from compiled code)?
GWT.isScript() and GWT.isProdMode() can't be used on the server side. So there must be an other way...

Jens

unread,
Nov 16, 2012, 5:33:48 AM11/16/12
to google-we...@googlegroups.com
As the server has no idea in which mode the client runs, the client has to tell it the server.

The default RpcRequestBuilder adds the header "x-gwt-permutation" to server requests to prevent CSRF attacks. It contains the permutation name in production mode and "HostedMode" when running DevMode. So maybe you can simply evaluate this header in the servlet.

-- J.

Nano Elefant

unread,
Nov 16, 2012, 6:37:45 PM11/16/12
to google-we...@googlegroups.com
Exactly what I was looking for.
Thank you!
Reply all
Reply to author
Forward
0 new messages