Results 1 to 4 of 4
  1. #1
    Nandini is offline Member
    Join Date
    Jan 2009
    Posts
    2
    Rep Power
    0

    Default Reading a value from a proeprties file Using JSp

    IS there any other way that i cud write a code in jsp for reading values from a properties file........

  2. #2
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    282
    Rep Power
    6

    Default

    a sample property file
    -----------------------
    myproperty.peroperty1=A
    myproperty.peroperty2=B


    jsp code
    --------
    <%@page import="java.io.*,java.util.*%">
    <%
    Properties pro=new Properties();
    FileInputStream fis=new FileInputStream("myproperties.property";
    pro.load(fis);
    fis.close();
    String prop1=pro.getProperty("myproperty.property1");
    String prop2=pro.getProperty("myproperty.property2");
    %>

  3. #3
    Nandini is offline Member
    Join Date
    Jan 2009
    Posts
    2
    Rep Power
    0

    Default

    Thnks a lot .

  4. #4
    neeraj.singh is offline Member
    Join Date
    Feb 2009
    Location
    Delhi
    Posts
    63
    Rep Power
    0

    Default

    Hi Nandini

    here is the code,
    how i am reading the property file in a jsp page
    Java Code:
    <%      
      try {
          java.util.Properties p = new java.util.Properties();
          p.clear();
          p.load(new java.io.FileInputStream("PropFile.property"));
          sUser = p.getProperty("user", sUser);
          sPassword = p.getProperty("password", sPassword);
        if (sPassword == null || sPassword.equals("")) {
          sPassword = sUser;
        }
          
       } catch (java.io.FileNotFoundException e) {
          System.out.println("File not found: " + PropFile.property );
       } catch (Exception e) {
          System.out.println(e);
       }
    %>
    thanks
    /\/ :)

Similar Threads

  1. Reading from csv file.plz help!!!!!!!!!!
    By sanjayksaini in forum New To Java
    Replies: 1
    Last Post: 12-19-2008, 08:41 AM
  2. Help reading file
    By fritz1474 in forum New To Java
    Replies: 4
    Last Post: 09-17-2008, 04:28 AM
  3. reading csv file help
    By fritz1474 in forum New To Java
    Replies: 5
    Last Post: 09-04-2008, 09:41 PM
  4. Reading a file
    By mew in forum New To Java
    Replies: 2
    Last Post: 12-30-2007, 01:23 PM
  5. Reading a file for use
    By peachyco in forum New To Java
    Replies: 2
    Last Post: 11-27-2007, 04:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •