struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Hardy <>
Subject Re: Use struts module with relative url path when forwarding request from webserver
Date Sun, 09 Apr 2006 16:26:50 GMT
I can't visualise what the final URL looks like in the browser in your 
situation with the webserver in-between.

Try using the <html:base> tag.

Scott Zhu on 07/04/06 19:35, wrote:
> Thanks. The problem is that we can't use absolute path (leading "/")
> because we are forwarding the request from webserver to app server.
> So even we move them into common, we still have to use relative path
> to point to them.
> On 4/6/06, Adam Hardy <> wrote:
>> Scott,
>> try placing the shared javascript in a 'common' module and refer to
>> it using a leading slash src="/common/js/base"
>> Adam
>> Scott Zhu on 06/04/06 18:25, wrote:
>>> 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.jpgfor 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/, it forwards to 
>>> http://as:port/APP/module/, 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:
>>> 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
>> performanceication for this also.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message