- This topic has 3 replies, 2 voices, and was last updated 18 years, 6 months ago by Riyad Kalla.
-
AuthorPosts
-
bryon1409MemberI have a struts web project that has jsp files under WEB-INF.
<webapps> <app> index.jsp <scripts> dothis.js dothat.js <WEB-INF> important.jsp secure.jsp
The jsp files under WEB-INF reference the js files under <scripts> as such:
<script language=javascript src="scripts/dothis.js"></script>
The javascript debugger works fine, but the code completion doesn’t work at all. The CTRL-click feature to load the js file in the editor also does not work.
If i change the script include to:
<script language=javascript src="../scripts/dothis.js"></script>
The code completion and CTRL-click features work, but then jsp’s never find the script file because the relative path doesn’t exist at runtime (since the path is based on the <app> root …i.e. webapps/scripts doesn’t exist).
Is this a known issue? Is there a workaround?
Thanks
Bryon
Riyad KallaMemberBryon,
This is tricky because the WEB-INF dir is special. For example, how do you reference your images from that location in your JSP pages? Especially if the page is in a “jsp” subdirectory? How should the IDE treat this directory?
bryon1409MemberHi,
I only place JSP’s under WEB-INF, all other resources are placed in the webapp directory (and subfolders). I reference the resources relative to the webapp root, not the JSPs under WEB-INF (because that’s how the browser will resolve the paths). So if I have a jsp file app/web-inf/jsps/secret.jsp and my images are in app/images, then I reference them from secret.jsp as “images/mypic.jpg”. If you reference your files relative to the page when they’re under WEB-INF, your app won’t work since browsers can’t see resources there.
I think the best way to handle this is to have the IDE lookup HTML resource includes (script src, hrefs, etc) based on the webapp dir instead of relative to the page when the page is under WEB-INF. That is how the browser will look for them. JSP includes should remain relative to the page.
Anyone agree/disagree? Comments?
Thanks!
Bryon
Riyad KallaMemberBryon,
Thank you for the detail, I believe we have a bug filed on this, if we don’t, I’ll file a new one, if we do I’ll add your comments. -
AuthorPosts