• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Servlet Cannot find Find Properties File

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem occurs when attempting to load a properties file in a servlet.

The batch job works OK. So I cut and paste the batch driver (GBTest01) into the servlet.

The servlet fails :


What's missing ? Thank you for any help.

The Properties File Directory :


The Classpath : C:\apache-tomcat-6.0.18\webapps\GBForms is in the classpath (the batch program found it).

The Batch Driver :

The Properties File Loader : used by batch and servlet

The Servlet :
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Servlet containers like Tomcat ignore your environment CLASSPATH - look at the class-loader-howto.html file normally installed with Tomcat in the "docs" under webapps.

2. The servlet API provides a mechanism for locating files in the web application. See javax.servlet.ServletContext API for methods like getContextPath, getRealPath.

Bill
 
Graeme Byers
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your reply.
By tinkering around I found that placing the properties file in WEB-INF/classes works.
I will read the documentation.
Graeme.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic