Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Zimlets

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-26-2009, 12:27 PM
Trained Alumni
 
Posts: 342
Default Reading a Java properties file from JSP.

Hi,

I've created a Java properties file in my Zimlet and am trying to read the values from it in JSP. The following code does not work...
Code:
    private String GetProperties(String prop){
        Properties props =  new Properties();
        String prop_val = "";
        //try retrieve data from file
        try {
            props.load(new FileInputStream("ldap.properties"));
            prop_val = props.getProperty(prop);
        }
        catch(IOException e){
            e.printStackTrace();
        }
        return prop_val;
    }
...so I'm assuming that I can't read it with FileInputStream, but will have to read it via a URL Stream like this instead...
Code:
<%
URL myURL=application.getResource("/WEB-INF/myfile.properties");
InputStream in = myURL.openStream();
Properties p = new Properties();
p.load( in );
out.println( p.getProperty("servername") );
%>
But I don't know what the URL path to that properties file would be. Also...if it's readable via a URL path by the JSP file....is it then also readable by the URL path in a browser by anyone? ...that would be bad.

I'm trying to abstract a bunch of customizable settings out of the JSP and into a properties file in the Zimlet....just having a little trouble getting it figured out.

Any thoughts?

Thanks,
Matt
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.