facebook

Javascript editor has problems with files under WEB-INF

  1. MyEclipse Archived
  2.  > 
  3. Web 2.0 / AJAX
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #247323 Reply

    bryon1409
    Member

    I 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

    #247333 Reply

    Riyad Kalla
    Member

    Bryon,
    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?

    #247371 Reply

    bryon1409
    Member

    Hi,

    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

    #247372 Reply

    Riyad Kalla
    Member

    Bryon,
    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.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Javascript editor has problems with files under WEB-INF

You must be logged in to post in the forum log in