geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ciAnd7 <>
Subject Request.getContextPath() after RequestDispatcher.forward()
Date Fri, 29 Feb 2008 13:29:57 GMT


I have a problem with  servlet container (tomcat) in geronimo. May be it is
not right mailing list for such question, so please point me right place.

I am using geronimo/tomcat 2.0.2. But the same problems appears in G2.1 too. 

My web-application should work under root server context. So, there is 
<context-root>/</context-root> in geronimo-web.xml (as suggested by welcome
screen of   "welcome-tomcat" app).

It works fine. But there is one problem - JSTL tag <c:url..> produce double
leading slashs. I.e.
<c:url value="/img/pict.gif"/> out put "//img/pict.gif" (without  quotes).
Most browsers don`t understand such urls correctly.  

Investigating problem I found that first redundant slash appeared as result
of request.getContextPath(). This method used by implementation of JSTL OUT
tag to generate leading part of url  (see
According to specification, method request.getContextPath() should returns
empty string for root context path (and such behavior is expected by Instead, it returns "/" if called in forwarded

For example, Servlet mapped to "/servlet" and calls 
RequestDispatcher.forward() to jsp page. After that in forwarded jsp page
c:url tag will generate double leading slashes. If Servlet use
RequestDispatcher.include() instead of forward(), than c:url tag generates
right urls.

I could provide simple application to demonstrate problem.

Any ideas?


View this message in context:
Sent from the Apache Geronimo - Users mailing list archive at

View raw message