AW: [opencms-dev] properties files

Mark Miller mark.miller at hema.ch
Fri Nov 28 16:59:01 CET 2003


Nice one ... thanks.

mark

-----Ursprüngliche Nachricht-----
Von: opencms-dev-admin at opencms.org
[mailto:opencms-dev-admin at opencms.org] Im Auftrag von Flavio
Gesendet: 28 November 2003 14:13
An: opencms-dev at opencms.org
Betreff: Re: [opencms-dev] properties files


Hi Mark.

Sorry for my poor English, but I don't speak English very well.

Here I report you some code that I wrote in a JSP to read a properties
file.

------------------------------------------------------------------------
------------------------------------------------------------------------
---------------------------------------------------

<html>
<head>
<title>Read properties file example</title>
</head>
<body>
<%!
public String addError(Exception e)
{
  return e.getMessage() + "<BR>";
}
%>

<%
java.util.Properties p = new java.util.Properties();
String err = "";
String test = "";

// Create a JSP action element
com.opencms.flex.jsp.CmsJspActionElement cms = new
com.opencms.flex.jsp.CmsJspActionElement(pageContext, request,
response);
com.opencms.file.CmsObject cmsObj = null;
com.opencms.file.CmsFile cmsF = null;
java.io.ByteArrayInputStream bais = null;
try
{
  cmsObj = cms.getCmsObject();

  cmsF = cmsObj.readFile
("/system/modules/ch.hema.opencms.modules.album/classes/ch/hema/opencms/
modules/album/workplace.properties");

  bais = new java.io.ByteArrayInputStream(cmsF.getContents());
  try
  {
    out.println("<BR>Lettura...");
    p.load(bais);
    out.println("<BR>Proprieta'");
    test += p.getProperty
("ch_hema_opencms_modules_album_AlbumBackoffice.label.name");
  }
  catch (java.io.IOException e)
  {
    err += addError(e);
  }
}
catch (Exception e2)
{
  out.println("<BR><B>Errore</B> " + e2);
  err += addError(e2);
}
%>
<BR><BR><BR>
<BR>test = <%=test%>
<BR>err = <%=err%>
</body>
</html>

------------------------------------------------------------------------
------------------------------------------------------------------------
---------------------------------------------------

I hope it's usefull.

Bye!!!

Flavio Suigo





 

                    "Mark Miller"

                    <mark.miller at hema.c       To:     "'OpenCMS Mailing
List'" <opencms-dev at opencms.org>                
                    h>                        cc:

                    Sent by:                  Subject:     [opencms-dev]
properties files                               
                    opencms-dev-admin at o

                    pencms.org

 

 

                    28/11/2003 09.50

                    Please respond to

                    opencms-dev

 

 





Can someone please explain to me either the standard way to get
properties
(eg. from a workplace.properties files) or why the code below keeps
giving
me a 'system cannot find file' error.





Thanks in advance,








Mark





************************************************************************
************





Properties p = new Properties();


FileInputStream file;


String err = "";


String test = "";





try {


  file = new FileInputStream(CmsFile.getAbsolutePath
("/system/modules/ch.hema.opencms.modules.album/classes/ch/hema/opencms/
modules/album/workplace.properties"));





  try {


    p.load(file);


  } catch (IOException e) {err += addError(e);}





  test += p.getProperty
("ch_hema_opencms_modules_album_AlbumBackoffice.label.name");





} catch (FileNotFoundException e) {err += addError(e);}


catch (SecurityException e) {err += addError(e);}










_______________________________________________
This mail is send to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please
visit
http://mail.opencms.org/mailman/listinfo/opencms-dev






More information about the opencms-dev mailing list