Ralph Goers wrote:
At 9/6/2004  02:55 AM, you wrote:

we've used this trick a number of times:

add an action with:

  public Map act( Redirector redirector, SourceResolver resolver,
    Map objectModel, String source, Parameters parameters)
    throws Exception
  {
    Request request = ObjectModelHelper.getRequest(objectModel);

if (request.getAttribute("mountpoint") == null) {
String mountpoint = "";
String requestURI = NetUtils.decodePath(request.getRequestURI());
String sitemapURI = request.getSitemapURI();
int pos = requestURI.indexOf(sitemapURI);
if (pos != -1)
mountpoint = requestURI.substring(0, pos);
request.setAttribute("mountpoint", mountpoint);
getLogger().debug("mountpoint=" + mountpoint);
} else
getLogger().debug(
"mountpoint=" + request.getAttribute("mountpoint") + " already set!");


    return null;
  }


This is a good technique, but I would change

    Request request = ObjectModelHelper.getRequest(objectModel);

to

HttpServletRequest request = (HttpServletRequest)objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT);

As Lars pointed out, Cocoon's Request object can sometimes point to an internal pipeline which is usually not what you want.


good remark,

I should have noted that we only put the action in on the public pipelines (ie not internal-only)

regards,
-marc=
--
Marc Portier                            http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at                http://blogs.cocoondev.org/mpo/
[EMAIL PROTECTED]                              [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to