BEA getRealPath for properties file

Posted on 2006-04-06
Last Modified: 2008-02-01
I have a properties file that I need to access within my web application.  I built it on JBuilder using Tomcat 4.1, and I call the following method to derive the path for my properties file...

session.getServletContext().getRealPath("/") + "/properties/";

In any case, it doesn't work when I deploy it to BEA.  The method return a NULL.  Any clue on how to retreive the application path of my project within BEA.  Thanks.

Question by:ispcorp
    LVL 29

    Expert Comment

    Because HttpSession.getSessionContext() is deprecated.

    Use either application.getRealPath("/") (for JSPs) or this.getServletContext().getRealPath("/") for servlets.
    LVL 35

    Accepted Solution

    Put the properties file inside WEB-INF/classes

    Then get at it via:

      InputStream is = this.getClass().getResourceAsStream( "/" ) ;

    LVL 35

    Expert Comment

    Weblogic will always return null if it's deployed as a WAR as well (according to all the sites I could find via google) :-/

    Apparently this is right according to the spec, and all other app servers are doing it wrong...


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    html form inside div 3 81
    servlet concurrency 13 80
    using if condition without JSTL 2 99
    maven project jars 7 41
    This is an issue that we can get adding / removing permissions in the vCSA 6.0. We can also have issues searching for users / groups in the AD (using your identify sources). This is how one of the ways to handle this issues and fix it.
    Outlook Free & Paid Tools
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now