struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Susan Bradeen" <Sus...@softlanding.com>
Subject Re: request.getContextPath() and Tiles
Date Wed, 18 Dec 2002 14:57:40 GMT
<snip>
> >
> > using the requestURI='request.getContextPath().concat("/showlist.do")'
> > gets me closer, but still not quite there.
> 
> 
> I can get around this by hard coding "myModule" into the path, such as 
...
> 
> requestURI='request.getContextPath().concat("/myModule/showlist.do")'
> 
> and the links are built properly, but I'd rather not do this. If there 
was
> a way to dynamically
> retrieve the application module prefix, I could get around hard coding.
> 

I have "resolved" the hard coding of the module path by doing the 
following ...

In the action, set the module-relative path in a request attribute:

public ActionForward execute(...) throws Exception {
        ...
        /*Build a module-relative path that Display tags can use for html:link 
"href=" parameter.*/
        ModuleConfig mc = (ModuleConfig) 
request.getAttribute(Globals.MODULE_KEY);
        request.setAttribute("linkPath", request.getContextPath().concat(mc.getPrefix()));
        return mapping.findForward("success");

}

then in the JSP retrieve the path attribute and add on the action ...

requestURI='<%=((String)request.getAttribute("linkPath")).concat("/showlist.do")%>'


There is probably a better way to do this, but this seems to work.

Susan Bradeen

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message