I've looked around a lot (trust me :) before posting this questions and I'm still confused. Here's the scenario:
Hosting a J2EE web-app on glassfish v3 using Restlet 2.0 The freemarker template files are located in the /WEB-INF folder. The templates link to jQuery/javascript files, some static images and stylesheets using relative URLs.
Since it's not a good practice to store them in /WEB-INF (as stated at many places on the web) I moved the files to the WebContent folder
WebContent:
+--Images
-.jpg, .gif files
+--Styles
-myStyle.css
+--Scripts
+--jQLabel
+--mColorPicker
+--Images
+--javascripts
-.js files
I refer to them in the freemarker template/html as:
<link rel="stylesheet" type="text/css" href="${baseRef}/Styles/myStyle.css" />
where ${baseRef}
is the Root Reference of the site. The site is deployed at /Winbook. So the URL on the localhost for the css looks like this:
http://localhost:8080/Winbook/Styles/winbookwall.css <-- retrieved using a GET
Problem(s):
For each of the above resources I get a 404 :( I'm not sure if this is really how one should store css, images or scripts and whether the WebContent folder is a good place for it be stored.
Question(s):
- Why is the above not working? I mean there has to be a mistake and I just don't know about it :)
- What is the best place to store the above files on the web server/glassfish?
- How do I refer to those resources (in the HTML/freemarker template) if they are deployed in the .war? (They will get deployed in the war file if they are placed in WebContent, right? Is this 'legal' or good practice? Seems to smell :)
- Do we have to create alternate doc roots in glassfish for all such resources (or the equivalent Directory class in Restlet?)
- What is the 'best' way/place of/for such a deployment for an intranet based application to seamlessly locate the resources? JNDI based lookup? (I don't know how that would work, another question probably on SO ;)
I am totally confused! It's been a while since I had to write a full end to end web app and this was usually taken care of by the 'others' :)
Thanks!