I have encountered a problem related struts module and would like to see if
you have any suggestions.

A new requirement for our webapp is to use a webserver to forward requests
to the real app server. So someone may request a url like:
http://ws/abc/APPand we configure it to forward to
http://as:port/APP. We have many places using absolute path for images and
hrefs, e.g. any places request.getContextPath() or some of struts html tags
are used. When this goes back to client, the webserver would try to append
it its root when it sees an absolute path (http://ws/APP/images/xxx.jpg for
example) which would be wrong. Most of them can be fixed by change to use
relative path instead. We also use a sub-module. When we say
http://ws/abc/APP/module/xxx.do, it forwards to
http://as:port/APP/module/xxx.do, then it found the mapping to its jsp, so
far so good, the problem is that in that jsp, we have something like this:
<script language="Javascript" src="<%=request.getContextPath
()%>/js/baseModuleFunctions.jsp"></script>
<script language="Javascript" src="js/moduleFunctions.jsp"></script>

If we eliminate the getContextPath() part, it will not be able to tell which
is from the base module and which is from its module. I guess the
fundamental problem is that we used to use getContextPath() to refer to
stuff in the base module from the submodule. And what can we do now to
accomplish that?

I did found one (possible) solution, is to change all module action urls to
this format:
switch.do?prefix=/module&page=/xxx.do

Basically all actions will be treated to come from the base module. Then we
change the above code to this:
<script language="Javascript" src="js/baseModuleFunctions.jsp"></script>
<script language="Javascript" src="module/js/moduleFunctions.jsp"></script>

But this requires some substantial changes. And I don't know the performance
implication for this also.
I'd appreciate any help from you.

-Scott

Reply via email to