I've seen Craig posted how something like
        <html:image page="/images/a.gif"/>
will get translated to
        <img src="/myapp/images/a.gif">

But I need to create a context-sensitive URL in Javascript. The reason for this is 
that 
there are multiple buttons on my form/page and in the action handler function for 
each button I need to set the form's action to the appropriate action for that button 
click before submitting the form. 

So I think I want a way to do get at info in Javascript that is the equivalent of what 
is 
returned by javax.servlet.http.HttpServletRequest req.getContextPath()

So that something like this can be done in Javascript
   this.form.action = contextPath + "/graphs/fullgraph.jsp"

(or .do instead of .jsp or whatever)

So is there some way with a Struts tag to put the context path on the generated 
page using perhaps an invisible control that would be set to have the context path as 
its value? Then one could assign the invisible control's value for the the context 
path 
to a Javascript variable and use it in something like the code snippet above.

I also need to do some other stuff in the Javacsript (eg set the target attribute of 
the 
form tag using a generated value as well). So I think I really need to use Javascript 
to 
do this.

Or am I approaching the problem in a way that is totally wrong? 




Reply via email to