GWT:帶有 db 變量的屬性文件的安全位置 (GWT: Safe place for properties file with db variables)


問題描述

GWT:帶有 db 變量的屬性文件的安全位置 (GWT: Safe place for properties file with db variables)

I have a file variables.properties in my GWT application inside the war folder. The file contains a jdbc string, username and password, hence I would not like to see it on the client side in any way.

My question: Is variables.properties somehow integrated into client side code at runtime when placed inside the war folder or is it safe to place it there?

If it is not, where should I put it? I read the file with this code:

variables = new Properties();
BufferedInputStream stream = new BufferedInputStream(new FileInputStream("variables.properties"));
variables.load(stream);
stream.close();

Thanks in advance!

‑‑‑‑‑

參考解法

方法 1:

If you don't want the properties to be visible to the GWT client code (or to a web browser poking around) you can load them from your classpath. That way they'll end up in WEB‑INF/classes which is not visible. If you're using Maven you can store your properties files in src/main/resources. Otherwise you can store them next to your Java source files and make sure they get copied during your build process. You can load them from the classpath by using: http://docs.oracle.com/javase/6/docs/api/java/lang/Class.html#getResourceAsStream(java.lang.String) 

(by devryscondit)

參考文件

  1. GWT: Safe place for properties file with db variables (CC BY‑SA 3.0/4.0)

#gwt #properties #server-side






相關問題

通過 GWT-RPC 發送持久的 JDO 實例 (Sending persisted JDO instances over GWT-RPC)

GWT:帶有 db 變量的屬性文件的安全位置 (GWT: Safe place for properties file with db variables)

paket khusus dalam toples eksternal GWT (specific packages in a external jar GWT)

在 gwt 框架中使用參數更改 url (Changing url with parameters in gwt framework)

通過 JavaScript 在標題或 HTML 中動態包含腳本元素 (Dynamically include script element in header or HTML by JavaScript)

Java如何在構造函數中將接口作為參數傳遞? (Java How do I pass interface as parameter in Constructor?)

如何更改 gwt 面板的內容? (How to change the content of a gwt panel?)

內容類型是“應用程序/x-www-form-urlencoded”。預期的“文本/x-gwt-rpc” (Content-Type was 'application/x-www-form-urlencoded'. Expected 'text/x-gwt-rpc')

如何從谷歌應用引擎調用我的應用網址 (How to call my app url from google app engine)

GXT NumberField 不可編輯 (GXT NumberField not editable)

在碼頭上部署 gwt Web 應用程序 (deploying gwt web application on jetty)

在 gwt 中使用 html5 畫布畫一個圓圈? (draw a circle using html5 canvas in gwt?)







留言討論