[Yanel-dev] Context path issue if Yanel deployed inside ROOT context

Michael Wechner michael.wechner at wyona.com
Tue Jul 12 01:15:02 CEST 2011


Hi

Yanel is setting various "global" cookies and hence the context path is 
set as cookie path.
The problem was that if Yanel is deployed inside the ROOT context (e.g. 
of Tomcat), then the method
HttpServletRequest.getContextPath() returns an empty string, but instead 
one should use a "forward slash".

I have fixed this now as follows

+        String contextPath = request.getContextPath();
+        if (contextPath.length() == 0) { // INFO: 
http://download.oracle.com/javaee/5/api/javax/servlet/http/HttpServletRequest.html#getContextPath%28%29
+            //log.debug("It seems like Yanel is deployed inside the 
ROOT context");
+            contextPath = "/";
+        }
+        //log.debug("Context path: " + contextPath);

but need to fix some more classes:

src/contributions/resources/davcollection/src/java/org/wyona/yanel/impl/resources/DavCollection.java

src/realms/welcome-admin/yanel/resources/show-realms/src/java/org/wyona/yanel/impl/resources/showrealms/ShowRealms.java

src/webapp/src/java/org/wyona/yanel/servlet/security/impl/AutoLogin.java

src/webapp/src/java/org/wyona/yanel/servlet/security/impl/DefaultWebAuthenticatorImpl.java

Will do this shortly.

It's not 100% clear to me if the above fix is the most elegant, or if 
one should rather use the context path of  the servlet context (which is 
sometimes hard to access though).

Thanks

Michael


More information about the Yanel-development mailing list