Sample uses a database table to create, get and set application property name/value pairs. Download here:
http://www.ebaseftp.com/download/sample ... 13_gsp.zip
Sample courtesy of Ian Bramford.
Get and set application property values
Moderators: Jon, Steve, Ian, Dave
-
- Ebase Staff
- Posts: 89
- Joined: Mon Sep 10, 2007 11:48 am
Get and set application property values
Last edited by Dave on Thu Apr 11, 2013 4:41 pm, edited 1 time in total.
0 x
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
You can also use a conventional properties file to hold application properties consisting of key/value pairs. Here's an example:
I have a property file called sysAdmin.properties. This should be located anywhere on the server's classpath, in my case in UfsServer/tomcat/webapps/ufs/WEB-INF/classes. The file content looks like this:
# sysAdmin.roles: comma delimited list of roles which allow access to the system administration app
sysAdmin.roles=SUPER_USER
# sysAdmin.users: comma delimited list of users which allow access to the system administration app
sysAdmin.users=user1,user2
Here's a script to read the sysAdmin.roles property:
I have a property file called sysAdmin.properties. This should be located anywhere on the server's classpath, in my case in UfsServer/tomcat/webapps/ufs/WEB-INF/classes. The file content looks like this:
# sysAdmin.roles: comma delimited list of roles which allow access to the system administration app
sysAdmin.roles=SUPER_USER
# sysAdmin.users: comma delimited list of users which allow access to the system administration app
sysAdmin.users=user1,user2
Here's a script to read the sysAdmin.roles property:
Code: Select all
var propertyFileName = "sysAdmin";
var propertyName = "sysAdmin.roles";
var propertyValue = getStringProperty(propertyFileName, propertyName);
/**
* Read a string property from a properties file
*/
function getStringProperty(propertyFileName, propertyName)
{
var props = java.util.PropertyResourceBundle.getBundle(propertyFileName);
if (props)
{
return props.getString(propertyName);
}
return null;
}
0 x
Who is online
Users browsing this forum: No registered users and 21 guests