Where to put inf File so Servlets can read it?

Hi
I have a .inf file that contains the location of a database and of my smtp server. I have some servlets that make calls to java classes that read this file in order to access a DB and send emails etc. Where should i put this file so that when i come to run my project on apache the servlets and java classes can see and use the inf file? Do i need to put it in the WEB-INF directory etc? Do i need to add anything to the Web.xml file etc?
Thanks
David

Thanks, ive set it up so it now uses a properties file which is placed in the same package as the class file on apache. But in order to read the file i need to put an absolute path in e.g.
Properties props = new Properties();
props.load(new FileInputStream("C:/apache-tomcat-6.0.10/webapps/ROOT/WEB-INF/classes/coreservlets/message.properties"));
however i want to use a relative path, somethin like:
props.load(new FileInputStream("/message.properties"));
but this does not seem to work, do i need to define a realtive path using different syntax or do i need to place the properties file in a different place or change some configuration settings in apache?
Thanks
David

Similar Messages

  • How do I get Firefox to ask me where to put a file I wish to download

    When I download a file, Firefox puts it somewhere. I want to be able to tell it where to put that file each and every time.

    Options > General - Downloads = '''Always ask me where to save files'''

  • Separated trace file which I can read with the log viewer

    Hi All,
    I 'd like to write trace infomation.
    I know I can use the default trace.
    But I 'm looking for a way to write my application information in a separated file,
    which I can read with the log viewer.
    Can someone help me with this
    Thnaks
    Steve

    Hi epexpert,
    thaks for your reply.
    I tried it with the Filelog.
    The Problem is that it logs to the file (its not problematically) but also to the defaulttrace
    and thats not my preferred solution.
    Do you have any other ideas?
    Bye Steve

  • Where to put props file

    Hello,
              when using a WAR application to deploy a servlet, which uses a
              ResourceBundle to read a properties file, where should the properties file
              be put in the .war directory structure.....I put it in WEB-INF/lib, but that
              does not work....
              regards,
              Farhat
              

    I have a similar question - I'm not using Resource Bundles, but I want to be
              able to set some properties, from my program/servlet/jsp. If I include it in
              the WAR file, I can't set them. Where is a recommended spot for properties
              files to live?
              -Ketan
              Charlie Crook <[email protected]> wrote in message
              news:3a702ec4$[email protected]..
              > The properties file has to be available to the jvm - hence in the
              classpath.
              > But if the properties file is only as an .ini replacment by that
              particular
              > servlet, why not just move all the information from the properties into
              some
              > init parms for the servlet - in web.xml?
              >
              > "Muhammad Farhat Kaleem" <[email protected]> wrote in message
              > news:3a6fe9d7$[email protected]..
              > > Hello,
              > > when using a WAR application to deploy a servlet, which uses a
              > > ResourceBundle to read a properties file, where should the properties
              file
              > > be put in the .war directory structure.....I put it in WEB-INF/lib, but
              > that
              > > does not work....
              > >
              > > regards,
              > > --
              > > Farhat
              > >
              > >
              > >
              > >
              >
              >
              

  • Where to put jar files reachable for ejb:s?

    Hello!
    I have a ejb that use some jar files.
    But I can not figure out where to put the jar files that I use from my ejb in Weblogic 8.1.3.
    Until now I have extracted all jar files and put them inside my ejb with my own class files. But this seems odd.
    So please help me out here.
    Best regrads
    Fredrik

    Dear,
    You might have downloaded either tar.gz or zip file. when you extract this file you will find a jar file and also some demos nad docs(api+help). place the poifs api jar file in 'WEB-INF\lib" folder and restart the server.
    In general any api jar files for web applications should be placed in WEB-INF\lib folder then only they are accesible. If you extracted the jar, then place entire package structure in WEB-INF\classes directory
    Regards,
    Nishant Kulkarni
    Software Engineer
    Bangalore
    [email protected]

  • Where to put javascript files.

    I am working in Apex 4.0.
    I have found javascript code titled accounting.js. It is available at http://josscrowcroft.github.com/accounting.js/
    The instruction on use of the code are as follows:
    "Download the script and put it somewhere, then do this:
    <script src="path/to/accounting.js"></script>
    <script type="text/javascript">
         // You can do this now:
         accounting.formatMoney(5318008);
    </script>"
    The accounting.js file is over 30,000 characters. Where do I put it so that I can reference it from any page in my application?
    Then what do I need to do on a page where I want to use it?

    You have two options. Both involve modifying your page template to include the file, but you have options on where to place the file.
    1) Place it in the images folder in your application server, and refer to it using the IMAGE_PREFIX substitution string
    <script src="#IMAGE_PREFIX#accounting.js" type="text/javascript"></script>2) Upload it into your Apex repository as a workspace file (Shared Components -> Static Files) and access it from the database.
    <script src="#WORKSPACE_IMAGES#accounting.js" type="text/javascript"></script>Scott

  • Where to put property files used by XSLT extensions?

    Still fighting with Java XSLT extensions. I have narrowed the
    problem down: my XSLT extension cannot find its property file,
    which I use to store JDBC connect strings etc.
    What is the proper directory to put this file so the XSLT
    extension class can find it? I am using Oracle HTTP Server with
    XDK 9.0.

    Thanks for the answer, Steve!
    Depends on what call you're using in your extension function to
    read your properties.Maybe I tried a too simplistic approach. I'm just using this:
    Properties props = new Properties();
    try {
    props.load(new FileInputStream("/foo.properties"));
    etc.
    This (with the slash) works if the properties file is in the root
    directory of the filesystem, but it's a kludge.
    If you read your properties as a resource using
    getResourceAsStream(), then where the classloader expects to
    find your file depends on the resource name that you specify.So maybe I should use getResourceAsStream() then? What if I put
    the properties file inside the JAR with the extension classes?
    Or is there any way to reference the web root?
    --Jere

  • Where to put .txt file with SimpleInput

    Hello everyone,
    I'm rather new to Java and have a slight problem. The thing is that I need to write an app that can read a text file in this format:
    2
    Orc
    name = Gnorck
    experience = 20
    maxHealthPoints = 50
    healthPoints = 30
    maxBerserk = 9
    berserk = 7
    Human
    name = Aragorn
    experience = 45
    maxHealthPoints = 40
    healthPoints = 30
    maxGreed = 20
    greed = 10
    The first number is de number of characters in the file and after that every character is described in 7 lines.
    Now the application has to be able to read the file. I've choosen to first just make a list of characters. A friend helped me with this code but I'm not completely sure if I know how it works. The code:
    package RPGApplicatie;
    import java.util.*;
    public class Karakters {
         //Constructor
         public Karakters(int size){
              karakters = new ArrayList(size);
         //Methode voor het toevoegen van een karakter
         public void voegToe(Karakter k){
              karakters.add(k);
         public static Karakters readFile(String filename) throws ClassNotFoundException, RuntimeException, InstantiationException, IllegalAccessException{
              SimpleInput file = new SimpleInput(filename);
              int size = file.nextInt();
              Karakters result = new Karakters(size);
              for(int i = 0; i < size ; i++) {
                   Class c = Class.forName(file.nextLine());
                   result.voegToe((Karakter)c.newInstance());
              return result;
         //Variabelen aanmaken
         private ArrayList<Karakter> karakters;
    }First question: I have the classes Karakter (which is the superclass for class Human and Orc), Human and Orc. So does the method forName scan for strings that are also classes? Like so it scans the file and when it comes across a line that says either 'Orc' or 'Human' it adds it to the list?
    Second question: Where to put the text file that holds the data? I now have it in the same folder called test.txt. I use this code to run it:
    package RPGApplicatie;
    public class RPGApplicatie {
         public static void main(String[] args) throws ClassNotFoundException, RuntimeException, InstantiationException, IllegalAccessException {
              Karakters.readFile("test.txt");
    }Thanks in advance! If more info is needed I can post that.
    Regards,
    Sander

    I assume you have defined your Human and Orc classes to include fields name, experience, etc and a constructor that takes these values as parameters?
    You can remove the Class.forName() method altogether. Example:
    int count = file.readInt();
    // define variables for Karakter values (name, experience etc.)
    for (int i = 0; i < count; i++)
      String characterClass = file.readLine();
      // read common character components
      if (characterClass.equals("Human")
        // read human specific components
        karakters.add(new Human(...));
      if (characterClass.equals("Orc")
        // create Orc
    //...Cheers

  • Where to put Jar file?

    Hello,
    We are running the J2EE installation of ColdFusion, and I'm
    wanting to find out, is there a place on the server where I can add
    replace Jar files without restarting the JRun service?
    Thanks.

    lok2005 wrote:
    > Hello,
    >
    > We are running the J2EE installation of ColdFusion, and
    I'm wanting to find
    > out, is there a place on the server where I can add
    replace Jar files without
    > restarting the JRun service?
    >
    > Thanks.
    >
    Yep, depending on your installation type (stand-alone or
    multi-instance)
    you can put jar files in the lib directory of the JRun server
    and
    they'll get picked up without a restart. In the
    multi-instance
    installation this directory is {JRunRoot}\servers\lib, so on
    a typical
    Windows box this would be C:\JRun4\servers\lib. For a
    standalone
    installation it would be C:\CFusionMX7\lib
    Hope that helps,
    Matt
    Matt Woodward
    [email protected]
    Adobe Community Expert - ColdFusion

  • Where to put .txt file for easy I/O

    Hi,
    I'm creating a program to run psychological experiments, and I want to make it easy for future researchers to change the lists of stimuli.
    I'm planning on having a set of .txt/.csv files containing the lists, which can be easily modified by anyone. My question is, where do I put them?
    My guess is the easiest solution would be to put them in the same folder as the .jar file, but not to actually include them in the .jar file, as this would make it difficult to edit. So how would I refer to the path name of the list in my program? And, when testing the program as it's being written, should I put the files in the /dist folder that NetBeans created?
    Second question: I want to find and load any and all txt files that may be in the folder (assuming this is where they will go). I won't know ahead of time how many lists there will be. What's the easiest way to do this?
    Thanks!

    Alright, two questions:
    1) To find the files, can I just use some modified form of
    String[] filenames;
              File f = new File(".");
              filenames = f.list();I assume that there's some way of doing the same thing one level up on the directory tree, and then selecting only those files that end in .csv? Is it preferable to use the method that was mentioned above?
    2) I'm still a little confused as to where the files should go. Here in NetBeans, when I use the command above it gives me everything in the very bottom folder, including /dist, /src and everything else in that folder, even though the .jar file itself is located in /dist.
    Is NetBeans not actually running the program from the .jar file?
    When I distribute the code, should I assume that the "File f = new File(".");" will give me everything in the folder where the .jar is sitting?
    [Edit: I've solved #2 myself -- sorry about that. The answer seems to be "yes" and "yes": when testing, I should put my .csv files in the bottom folder, when distributing, I should put them in the folder with the .jar file. I can't do it ahead of time, as NetBeans recreates the /dist folder each time the project is re-built.]
    Thanks!

  • Where to put Jsp File?

    Hi!
    I am using Apache-tomcat web sever. To run my
    jsp progam where to put my jsp file?
    Thanks.

    Hi
    you can place your jsp file in webapps/ROOT/ directory.

  • Where to put ASE files

    Once I download the ase files I can't quite figure out where
    to put them so that when I'm using Photoshop or Illustrator or any
    Adobe application they will show up as option for me to select from
    in the swatches palette. Any advice would be appreciated.
    Thanks!

    Thanks for the tip. It was helpful. By doing that I realized
    that I could store the .ase files in the same place Adobe
    Photoshop, Illustrator, In Design, and Go Live currently store the
    swatches.
    I have CS2, and this is where I found the current storage of
    swatches.
    C Drive > Program Files > Adobe > Adobe Photoshop
    CS2 (or Illustrator, In Design, Go Live) > Presets > Color
    Swatches/Swatch Library/Swatches (depending on the app)
    Then I tested each out in that particular application and
    they worked beautifully. The only thing that stinks is that you
    have to put the .ase file in each Swatch folder for each one of the
    applications so in my case that was 4 times. I guess you could keep
    them in one central place and then access them from all
    applications.

  • Using Third-Party jar file in database; Where to put license file?

    Hi!
    I have a third-party product that has a .jar file that references some .so files. I have successfully loaded the .jar file and the .so files are being called successfully, but when the program gets to the part where it reads the third-party license file, it is failing (ORA-3113 and an hs_err_pid<12345>.log and udump file are created. I know the issue is the location of the license file because I am getting the same exact error when I run it outside of the database. (I have been able to run it successfully outside of the database.)
    The instructions for the third-party product say to put the license file in the application's runtime directory.
    What I can't figure out is this: What is the application's runtime directory when I am running the code in the database?
    I thought it would be user.dir which is set to $ORACLE_HOME, but putting the license file there didn't work. I have tried lots of other places under $ORACLE_HOME.
    Any ideas?
    Thanks,
    Laurel

    Hi Laurel:
    Whether or not you can read the license file, sure you will have problem then when trying to load your .so file.
    Java JNI call are not allowed inside OJVM for security reasons, see Kuassi's answer to a similar question:
    Access Berkeley DB from Java Stored Procedure
    Best regards, Marcelo.

  • Where to put the file?

    Hi, I have been trying to sort my 'import' problem and no luck so far, so I'm going to try a different approach.
    Right I have this in my code.
    import EasyIn.*;
    Where should the 'EasyIn' file be place relative to this class that has the import function in?
    At the moment in time Have the class 'EasyIn' in the same folder as this class but it is not seaming to work.
    Thanks for any help.

    Thanks this has worked, this is so strange because i have had to use the import function when I was using the University computers, must because of the way the hdd are arranged (servers etc)
    Thanks alot

  • Where to put properties files in EJB?

    is there a good standard place to put properties files for EJB?

    files. i wanted to jar everything together in a single
    ejb jar, and need to know if there is a standard or
    good place to keep those properties files so that
    whenever i move the ejb jar i dont have to worry about
    the paths to find those properties files.??? Both of my suggestions allow what you want. Neither one requires knowing any kind of file path. For example, packaging a properties files as my/fancy/data.properties entry in a jar will allow loading it as Properties ps = new Properties();
    ps.load (getClass().getResource("/my/fancy/data.properties").openStream(); (better code would also close() the stream in a finally block)
    The above depends on how the jar was packaged, not on its actual disk location.
    What's more, Class.getResource() also allows for package name-relative resource lookup which is convenient sometimes: http://www.javaworld.com/javaworld/javaqa/2002-11/02-qa-1122-resources.html

Maybe you are looking for