cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Fagerstrom <dani...@nada.kth.se>
Subject Re: ${cocoon.request.contextPath} returns null in 2.2
Date Sun, 28 Jan 2007 19:45:21 GMT
Grzegorz Kossakowski wrote:
> Hello,
>
> I'm hacking now ajax and forms block to get them use of servlet-services
> and came across a bug. When you put ${cocoon.request.contextPath} into
> JX template it will always return null (at least while using servlet
> dispatcher). However, ${cocoon.request.requestURI} returns valid value,
> so it must be only contextPath broken somehow. Unfortunately, I have no
> skills to debug this.
> Anyone can at least confirm this? Can you test it without servlet
> dispatcher? (I would do it myself if I knew how)
>   
I have not tested it. But looking at the code the servlet dispatcher 
just embeds the request object from the servlet container with a proxy. 
And the proxy doesn't affect the contextPath AFAICS, so it might be that 
the context path is null in the original request.

For a servlet service that is called through the servlet protocol, the 
contextPath will always be "", which is a bug. Currently the request 
object of the calling servlet service is not available in the servlet 
source, so there is no easy fix. I plan to refactor the call stack and 
make it available there.

In the servlet architecture we have:

requestURI = contextPath + servletPath + pathInfo

As the servlet service architecture creates an extra level of paths 
relative to the servlet architecture there are several possibilities 
where to add the mountPath.  I solved it in the following way: the 
dispatcher servlet will look for the mountPath that is the longest 
prefix in the incoming pathInfo. It will then create a new servletPath 
and pathInfo for the called servlet service:

newServletPath = servletPath + mountPath
newPathInfo = pathInfo.substring(mountPath.length())

So as you can see the contextPath will be the same as for all servlet 
services.

/Daniel


Mime
View raw message