Gidday,
I've been going through Marty Hall's CoreServlets book which has an example of a protected page
servlet, which uses a properties file for checking the passwords.
I can't seem to get the servlet to work.
I have done the following:-
1) Created the properties file using the book's program PasswordBuilder.java
2) This has created a properties file in the following directory as shown below:-
c:\tomcat\webapps\ROOT\WEB-INF\classes\coreservlets\passwords.properties
3) I then add the following to the the web.xml file located in the WEB-INF directory as follows:-
<servlet>
<servlet-name>
ProPage
</servlet-name>
<servlet-class>
coreservlets.ProtectedPage
</servlet-class>
<init-param>
<param-name>
passwordFile
</param-name>
<param-value>
"passwords.properties"
</param-value>
</init-param>
</servlet>
4) Placed the ProtectedPage.class file into the directory above
5) Started up
Tomcat server
6) Started up browser and gone to address:-
http://localhost/servlet/coreservlets/ProtectedPage 7) The tomcat error page comes up with an error trace which points to the third code line in ProtectedPage.java shown below:-
String passwordFile = config.getInitParameter("passwordFile");
Properties passwords = new Properties();
passwords.load(new FileInputStream(passwordFile));
What is the matter?
Where should the passwords.properties file be placed?
How should this be entered in the web.xml file?
Any help would be much appreciated!
Regards