I have tried a few things to do this GWT, didnt work, and then I made a .txt file with the assignments, and used java.util.Properties to so this. It works at times and at others does not is the problem. When I do a PutMethod to one of these variables stored in the .txt file through eclipse, running it as a java app, it works fine, it finds the ConstantVariables.txt file and goes through the keys to find the correct variable.
But when I try to do this through a a webpage, and not as a java app, I get a message telling me it cannot find the entity WebContent/ConstantVariables.txt, or something along those lines. Its probably an issue with Tomcat not putting the .txt file in the right place or something like that, Tomcat always gives me problems...
Can someone tell me where the problem may be coming from? Or if there is just a simpler way to do this? Right now I have to put in code to load up the .txt file and name it p, and then to p.getKey("variableName"), and such. Is there just a way to make a .properties file, and do some kind of import or something in the java code, where I can just use variableName instead of the whole p.get("variableName") stuff? It seems like this would be something that us used often and that there should be an easier way than needing all this extra code to do this,
But the main problem is the first I mentioned, that when I try to use this through webpages it doesnt find the .txt file.
True wisdom is in knowing you know nothing - Socrates
Use ServletContext.getRealPath when you're using servlets / JSP pages. This will be relative to the web app folder. For instance, inside a servlet, the following will print something like "C:\Program Files\Apache\Tomcat\webapps\myWepApp\WEB-INF\myFile.properties":
edit - nevermind, instead of using that I just went to the necessary file right-clicked and went to properties to see the full path name laughing out loud - easier than trying to figure out why I couldnt make the above line of code work