Wednesday, March 4, 2015

GWT / GXT: difference between WEBAPP and RESOURCES project's directories in storing resources e.g. images, css

Basic things you should remember about RIA structure:

WEB-INF directory holds everything on server e.g. Apache Tomcat servlet container lets say in "private" access i.e. nothing there is assessable by direct URL, only through the call to the server made by your app. 

This means that WEB-INF resources are accessible to the classloader of your Web-Application and not directly visible for the public.
-----------------------------------------------------------------------
So: if you'll store your resources in webapp directory, then after the build all that resources WILL HAVE public access e.g. directly assessable for everyone from their browser e.g. by URL.

If you want to insure your resources privacy e.g. images, css, properties etc you should put them inside of resources directory, NOT in webapp. Thus, after build they will be copied (stored) in WEB-INF directory.

Nevertheless, all your resources you use and store in your packages inside of src/main/java tree will be stored thereafter in WEB_INF/classes along with compiled source, which is not good because they should not be compiled. For this reason it is better to create some public directory for them on the same level of *.gwt.xml or in resources directory.