开发者

call a servlet onload from a GWT application

开发者 https://www.devze.com 2023-01-15 16:24 出处:网络
I need to read database properties from server.xml and need this information on load of the page.How do I acheive it in G开发者_开发百科WT ?I am not sure if there is anything specific to GWT. But I gu

I need to read database properties from server.xml and need this information on load of the page.How do I acheive it in G开发者_开发百科WT ?


I am not sure if there is anything specific to GWT. But I guess you could use

Servlet.getResourceAsStream

Or if you use JSP, you could use the application implicit object to get the ServletContext and you can use getResourceAsStream

Some pointers here and here


In your onModuleLoad() call an RPC through a

DeferredCommand.addCommand(new Command() {
    public void execute () {
      getDBParameters();
    }
  }

where getDbParameters is a method that populates the values for you by calling an RPC.

See http://code.google.com/webtoolkit/doc/latest/DevGuideServerCommunication.html for how to communicate with server.

On the Server side just have your RPC return a HashMap of properties and read those.

0

精彩评论

暂无评论...
验证码 换一张
取 消