Struts Modules and visibility of the overall application

L

L Ballard

Hi,

We're writing an application using Jakarta Struts as the framework,
and I'm attempting to separate a section of the site (as struts-config
is becoming so huge) into its own module.

The problem I have is this - I don't want the module to be
*completely* independant of the rest of the site - I want to be able
to access global resources so that I don't duplicate them within my
module. I am using the struts HTML tags to perform path rewriting for
me too. so:

I have a directory structure:

\module1\myJsp1.jsp
\global\scripts\script1.js

If, within myJsp1.jsp I want to use the global script I have defined
without hard coding the context root into my page, I tried to use:

<script src="<html:rewrite page="/global/scripts/script1.js" />"
language="JavaScript"></script>

however this renders the following (relative to the module):
<script src="/Context_Root/module1/global/scripts/script1.js"
language="JavaScript"></script>

so I tried with the href instead (html:rewrite tag needs either
"page", "href" or "forward" attribute defined):

<script src="<html:rewrite href="/global/scripts/script1.js" />"
language="JavaScript"></script>

which renders the path without the context root of the application:
<script src="/global/scripts/script1.js"
language="JavaScript"></script>

So that doesn't find the resource either. Finally I tried defining an
Action Forward in struts-config.xml. This was not visible to the jsp
(because I'm now in module1) so I added the following to
struts-config-module1.xml:

<forward name="JAVASCRIPT_GLOBAL_INCLUDE"
path="/global/scripts/script1.js" />
and tried:
<script src="<html:rewrite forward="JAVASCRIPT_GLOBAL_INCLUDE" />"
language="JavaScript"></script>

which rendered the following (relative to the module):
<script src="/Context_Root/module1/global/scripts/script1.js"
language="JavaScript"></script>

So is it at all possible (without any hard coding of paths) to use
resources defined for other (or the default) modules? It seems pretty
useless if it can't, that's why I'm convinced that there must be a
way, I just can't find it.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top