Hi
I am trying to run a web application which involves initialization of a
servlet with the name of a txt file (chatProps.txt) from which information
will be loaded. My problem is that I do not know where to put this txt file
in the web application directory and/or how to refer to it in the web.xml
file. The directory structure looks like this:
tomcat
|
webapps
|
chat (chatProp.txt goes in here(at the moment))
|
Web-inf (web.xml goes in here)
| ----- lib
|
| ----- classes
|
chatApp (All classes go in here)
All my classes are in chatApp. The web.xml into the Web-inf directory and
I've put my chatProps.txt file into the chat directory . The chat directory
is the root directory for the web application. The servlet code to load
this
file looks like this:
public void init() throws ServletException{
String propsFile = getInitParameter("chatProps");
if (propsFile == null || propsFile.length() == 0){
throw new UnavailableException("chatProps not set in servlet init
parameters ");
}
Properties props = new Properties();
try{
// THIS NEXT LINE THROWS THE EXCEPTION(below)
FileInputStream is = new FileInputStream(propsFile);
props.load(is);
is.close();
}catch (Exception e)
The web.xml for the web application looks like this(although recently it
has
looked like many things):
<web-app>
<display-name>chat</display-name>
<servlet>
<servlet-name>ChatAdminServlet</servlet-name>
<servlet-class>chat.ChatAdminServlet</servlet-class>
<init-param>
<param-name>chatProps</param-name>
<param-value>chatProps.txt</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
</web-app>
The exception I get is this:
Error: 503
Location: /chat/servlet/ChatAdminServlet
Can't read the chatProps file chatProps
java.io.FileNotFoundException: chatProps.txt (The system cannot find the
file specified)
Service is permanently unavailable
Where do I put the chatProps.txt file so the system can find it? How do I
refer to the chatProps.txt file in the web.xml file? The tag that I think
is
giving me the problem is <param-value> I've referred to the chatProps.txt
file in this tag with an absolute address, with a localhost:8080 address
etc. and now I am out of ideas.
Any help would be very much appreciated!!!!!!!!
Tony