Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 745
  • Last Modified:

BEA getRealPath for properties file

Hello,
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/myprops.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.

0
ispcorp
Asked:
ispcorp
  • 2
1 Solution
 
bloodredsunCommented:
Because HttpSession.getSessionContext() is deprecated.

Use either application.getRealPath("/") (for JSPs) or this.getServletContext().getRealPath("/") for servlets.
0
 
TimYatesCommented:
Put the properties file inside WEB-INF/classes

Then get at it via:

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

Tim
0
 
TimYatesCommented:
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...

Tim
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now