I am developing a Java Web application with Spring MVC and I am having a little problem in here.
I am sending .css files to W3C to validate the code, this part work just fine (the validation part), but to do this I need the route of the .css files in my project so I can create the file object and send it to the W3C.
I do not know how to (in my logic) write the path to the css files. I do not want to use absolute paths so I can move my app to any server without problems.
After deploying the project the WAR its moved to the servlet and the structure of the project folder is not the same than the WAR!
I have no idea how to tell to my logic where to find the .css files!
Ok I figure it out how to do this! Here its how
So what Im doing here ? first of all I get the name of the class im in, then I use the getResource of my class and ask for the path of it! Thits its giving me the path of the hole project in the server (/home/bterra/OneX/WEB-INF/ etc etc)!
Now I have the info a wanted! the route of my project in the server! Then I just split the string in “WEB-INF” to get the server path to concat later the name of the folder where my css are and the name of the css I want to validate!
I sure this its not the best way to do this … but it works for me! If you guys know a better way or the correct way to do this … plx let me know!
Thanks for all!