Nick Heiner
Nick Heiner

Reputation: 122450

Can GWT Properties be used from the server?

I have a GWT app that uses GWT RPC to talk to App Engine servlets. I would like to use constants defined in a .properties file on the server. Is that possible?

Upvotes: 2

Views: 2392

Answers (2)

Blessed Geek
Blessed Geek

Reputation: 21654

Use the GWT Dictionary class.

Declare you javascript objects in your html hosting file, then use Dictionary to retrieve them anytime after onModuleLoad.

Use JSP to construct your html hosting file - so that you could have a dynamically server generated set of constants. You can have a user-sensitive set of constants. Your servlet/jsp (JSPs are essentially servlets) would be able to read any property file or any database record within its reach on the server to create those constants.

Read this answer: GWT-Platform login + session management.

Upvotes: 0

BraginiNI
BraginiNI

Reputation: 586

To enable .properties in client you use

GWT.create(file_name.properties);

But this combination don't work on server-side, cause it's only availible on client-side, you'll get this error:

GWT.create() is only usable in client code!  It cannot be called, for example, from server code.

But, I suppose, you can use standard approach of processing .properties files like

Properties props = new Properties();
props.load(new FileInputStream("file_name.properties"));

And use a relative path, not an absolute path. It should work on GAE

Upvotes: 2

Related Questions