Andriy Kopachevskyy
Andriy Kopachevskyy

Reputation: 7686

run GWT on non java server

I think answer on my question is NO. But still, I'm wondering is it possible to run gwt applicaton as frontend for example on Apache HTTPD server. The idea that compiled gwt is pure javascript and don't need java backend (if we don't use java based RPC)

Upvotes: 1

Views: 451

Answers (4)

Blessed Geek
Blessed Geek

Reputation: 21614

"I'm wondering is it possible to run gwt applicaton as frontend for example on Apache HTTPD server".

The answer is NO. GWT UI frontend does not run on any server at all. It runs only on a browser with Javascript enabled.

But if I ignore the language semantics of the question and answering the gist of it - the answer is Yes. Pardon me, but I think the language you should have written is

"is it possible to SERVE the gwt applicaton frontend from an Apache HTTPD server".

Just deploy your servlet-less war onto the HTTPD (removing the WEB-INF folder).

In fact, you could even write RequestBuilder requests to request for static json streams from files placed in the GWT module development "public" folder. Where the GWT compiler would copy the contents of the "public" folder to the deployed application root.

Or you could use script-include to get your GWT client request for dynamic content jsonp from another server - which would not create any servlet in your app. I documented the script-include technique here: http://h2g2java.blessedgeek.com/2011/06/gwt-requestbuilder-vs-rpc-vs-script.html.

Upvotes: 1

dslh
dslh

Reputation: 1835

There's nothing stopping you. GWT code breaks down into two parts; server-side and client-side code. As you say the client-side code compiles down into pure javascript which can be easily served up by httpd.

The main advantage of using gwt's classes on the server is that data you request via RPC will arrive in your client code as java objects with no work on your part. But you can easily make calls to any old service using the RequestBuilder class, or XMLHttpRequest if you need more control.

Edit: There is one special bit of configuration you should do to make sure httpd works well with your client-side gwt code:

<Files *.nocache.*>
    ExpiresDefault "access"
</Files>
<Files *.cache.*>
    ExpiresDefault "now plus 6 months"
</Files>

This makes sure that when you upload a new version of the app users' browsers will download it automatically, but also makes sure that they won't download the entire app every time they visit your website. Very useful.

Upvotes: 3

Shantha Kumara
Shantha Kumara

Reputation: 3421

Your opinion is wrong. You can create a gwt application which is designed only for front-end. To test that you can do the following

  1. Create a sample gwt application which has only front end content
  2. Compile and build the application
  3. Place the build content folder in your Apache web directory.
    Ee : if you created a project called test-gwt, the JS and HTML contents are in test-gwt directory created inside the war directory.
  4. Access the new application through a web browser, like http://localhost/test-gwt

Hope this would help.

Upvotes: 2

Sascha
Sascha

Reputation: 947

That is possible and works like a charm as long as you don't write your server component with gwt.

Here is an simple gwt client only htaccess password app (currently only german) as an example, wich i've coded for fun.

Upvotes: 1

Related Questions