Discussions

Web tier: servlets, JSP, Web frameworks: calling property variable in jsp

  1. calling property variable in jsp (3 messages)

    I have a create a "test.properties" file. In test.properties file
    mod.filename="module"
    available. This properties file place in public_html directory in Java Web Server 2.0.

    In a jsp file I am calling the above properties file using "ResourceBundle" this way.

    try {
            ResourceBundle rb=ResourceBundle.getBundle("test");
            String str=rb.getString("mod.filename");
            out.println(errorpath);
          } catch (Exception e) {
              System.out.println(e);
          }

    When I am running the above jsp file using Java Web Server 2.0 then giving the error "cannot found resource test".

    What to do?
    Please send the reply to sngolla at rediffmail dot com.

    Thank You.
  2. Try putting test.properties in a directory that's in your classpath (any should work, system classpath, weblogic classpath, or webapp/servlet classpath).

    Andy
  3. Hi. Mr/Mrs. Andy Nguyen ,

    I followed your suggestion. But still it is not working. Kindly give the solution.
    Thank You.
  4. Why use seperate properties files? Instead, create a Java class that acts as a properties file. The JVM and a relational database are all that you need to run any project. Java projects are already complex enough. Why introduce a new place to keep important data? It sounds like the "public_html" directory is not the most secure place to keep valuable system parameters.