sharing web resources across modules

I've tried a couple of approaches with no success. Would appreciate some help.

I have several modules (web apps) in my intellij 11.1.5 project. I would like to share selected source (js, jsp, css) from one of my modules as web resources in other modules. For instance:

Mod1     /mod1
   src
         ...
   web
     shared
          my.js
          my.jsp
          my.css


Mod2     /mod2
   src
         ...
   web
     mod2_js
          mod2.js


I would like to make the contents of Mod1's shared directory available under the Mod2 web root (minimally at runtime) so that the following URLs work:

     http://local/mod1/shared/my.js
     http://local/mod2/shared/my.js


Thanks for your help.

2 comments
Comment actions Permalink

If you only need these files at runtime the simplest way is to include 'shared' directory into an artifacts layout: open File | Project Structure,
select 'Artifacts' item, choose web artifact for 'mod2' application and add 'shared' directory to the output layout tree using '+' -> 'Directory
Content' action.

--
Nikolay Chashnikov
JetBrains
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Nikolay, thanks for responding.

I've made the change you suggested but getting HTTP 404 when trying to get one of the "shared" resources of mod1 under mod2 url.

Specifically, given:

mod1
     web
          shared
               jsp
                    t.jsp

mod2
     web
          some.jsp

I added mod1 shared directory under mod2 artifact as Directory Content.

I tried to access t.jsp as http://local/mod2/shared/jsp/t.jsp and got 404.


What I noticed is that the mod1 shared directory (and its sub-directories) where copied under /out/artifacts/mod2_war_exploded but without any of the files contained in these directories.

What am I doing wrong?

Also, can you explain...if I change the contents of mod1/web/shared directory (or subs) will these changes automatically be reflected in mod2? That would be my intent.

Thanks.

jack

0

Please sign in to leave a comment.