I have 7 or 8 pages with common options like Home , Users etc. However when i change the address of home to something else then i have to go to each individual page and change the address both in servlets and jsp . Is there a way or a practice in which i could keep variables like Home_var some place. So that whenever i need to change an address i would just change that variable and all the links would pickup the address from that variable.
I am actually using Eclipse. I am not sure if its a runtime issue. What i mean is i need to keep a list of variables some where (Dont really know which place that would be??). Anyways these variables would have addresses attached to them like String Home = "index.jsp" . All my pages and servlets will have something like < a href=home>..</a> instead of <a href="index.jsp">..</a>. So is there some way i can accomplish this ?? OR is this a bad idea ??
Sure if you want to abstract the URLs for some reason there are any number of approaches. I personally wouldn't -- I don't see a real need for it and it could add an unnecessary level of obfuscation to the pages.
But if I were going to do this, I'd likely do it as follows:
Create a properties file that assigns URL values to keys.
Use a context listener to read the properties file on startup, and create a Map from the key/value pairs.
Place the Map in app context.
Use an EL expression to reference the URL by its key.
Joined: Oct 16, 2011
Any idea where that properties file should be placed ??