I am using the Struts 1 framework to develop a web application for my FYP. So far I have been able to access the properties file from all jsp in my application with example such as the following code.
I want to have the entire web application set up so that I can change to different languages from each page.
Another part of the application involves sending an automatic email to user when they sign up. I have a class called MailClient which sets up this email. I have hard coded the html into this class and it sends the email but really I want to reference a html file within the application in order to send this instead. To do this I have an entry in the properties file that points to the html file, but when I try to read in the properties file into the java class it is giving me a file not found error.
I have tried this using two different methods as follows:
Properties prop = new Properties();
FileInputStream in = new FileInputStream("ApplicationResource");
String message = prop.getProperty("welcome.newcustomer");
the properties file is called ApplicationResource.properties and the entry in it is as follows:
welcome.newcustomer = WelcomeMessage.html
2. This method was actually used by one of my lecturers for a project he worked on himself earlier in the year, we put the code into my project and received the exact same error.
File file = new File("ApplicationResource.properties"); ResourceBundle rs = ResourceBundle.getBundle("ApplicationResource");
String message = rs.getString("welcome.message");
when we implemented this it is still not finding the properties file. The error is as follows
java.io.FileNotFoundException: ApplicationResource (The system cannot find the file specified)
the properties file is in the same package as the java classes...
Any help with this would be fantastic, I just can't seem to see why its not working....:(
Thanks in advance!