You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by ciAnd7 <ci...@gmail.com> on 2008/02/29 14:29:57 UTC

Request.getContextPath() after RequestDispatcher.forward()

Hi!

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
/org/apache/taglibs/standard/tag/common/core/UrlSupport.java). 
According to specification, method request.getContextPath() should returns
empty string for root context path (and such behavior is expected by
UrlSupport.java). Instead, it returns "/" if called in forwarded
servlet/jsp. 

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?

Thanks.

-- 
View this message in context: http://www.nabble.com/Request.getContextPath%28%29-after-RequestDispatcher.forward%28%29-tp15758360s134p15758360.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: Request.getContextPath() after RequestDispatcher.forward()

Posted by ciAnd7 <ci...@gmail.com>.
Hi, Jacek


Jacek Laskowski wrote:
> 
> On Fri, Feb 29, 2008 at 5:29 AM, ciAnd7 <ci...@gmail.com> wrote:
> 
>>  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.
> 
> Could you verify if that happens on Tomcat alone too? This way we
> could cross Geronimo out from the list of possible suspects ;-)
> 
> 

FYI, here is small thread at Tomcat list  
http://www.nabble.com/Request.getContextPath%28%29-after-RequestDispatcher.forward%28%29-to15808317.html

I am not a Tomcat expert. As I see, the only correct Tomcat way to define
default (root) webapp is to name it ROOT... Or setting Context`s 'path'
attribute to empty string.
But it seems that Geronimo do it in differently (using '/' as Context`s path
attribute value?).  


--
andrey
-- 
View this message in context: http://www.nabble.com/Request.getContextPath%28%29-after-RequestDispatcher.forward%28%29-tp15758360s134p15823745.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: Request.getContextPath() after RequestDispatcher.forward()

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On Fri, Feb 29, 2008 at 5:29 AM, ciAnd7 <ci...@gmail.com> wrote:

>  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.

Could you verify if that happens on Tomcat alone too? This way we
could cross Geronimo out from the list of possible suspects ;-)

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl