简体   繁体   中英

Using a Configuration file server-side in GWT

I made a GWT App that use TCP/IP connections server side.

Now, I have harcoded the URL of the server that is used to connect:

private static final String URL = "https://localhost/ws";

I want to load this parameter from a config File like TOMCAT/conf/webService.conf or TOMCAT/conf/webService.xml but I can't find any propper way of doing this.

This app run in several servers and each server use a different WebService. I don't want to build a different app each time.

You may want to put such configuration in an XML or properties file on the server side. Then you can get this path at runtime from within a servlet

String path = getServletContext().getRealPath("/WEB-INF/classes/config");
File file = new File(path);
// Read as XML or properties file 

I realized that using Google app Engine won't let me load config files on the server. I'm not using GAE so I just disabled it and now I can use Config files.

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM