Portlet Factory, Version 6.1.2


 

Accessing other properties

You can access values stored in other properties files using Java conventions for loading properties files. For example, if you have created your own properties file or want to access other IBM® WebSphere Portlet Factory properties files, you can use code similar to the following to access those property values. This code gets the value of the application context property in the WebSphere Portlet Factory's install.properties file. Adapt this code to suit your needs:

{ String propertyValue = null; FileInputStream propertiesStream = null; String webInfDir = webAppAccess.getSystemProperties().getWebInfDir(); try { propertiesStream = new FileInputStream(webInfDir + "\\config\\install.properties");
catch (SecurityException se) { webAppAccess.getVariables().setString("SecurityExceptionVar", se.toString()); webAppAccess.processPage("ErrorPage");
catch (FileNotFoundException fnfe) { webAppAccess.getVariables().setString("FNFExceptionVar", fnfe.toString()); webAppAccess.processPage("ErrorPage"); try { PropertyResourceBundle propertiesFile = new PropertyResourceBundle(propertiesStream); String propertyKey = "install.webSphere.webModule.context"; propertyValue = propertiesFile.getString(propertyKey);
catch (IOException ioe) { webAppAccess.getVariables().setString("IOExceptionVar", ioe.toString()); webAppAccess.processPage("ErrorPage"); webAppAccess.getVariables().setString("PropertyValue", propertyValue);
}

Parent topic: Getting system properties


Library | Support |