tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ciAnd7 <cind...@gmail.com>
Subject Request.getContextPath() after RequestDispatcher.forward()
Date Mon, 03 Mar 2008 16:58:23 GMT

Hi!
I am using tomcat 6.0.13 on linux.
I try to deploy my application in to the root context. I.e. it should be
available as root application on one of  virtual host (http://vhost1/). So,
I add <Context ... path="/" /> into the server.xml (I know, it is not
recommended to do it in server.xml, but it is simple and I just want to do
simple testing right now).
The application works fine. But there is a problem with
request.getContextPath() method.  
My Servlets use RequestDispatcher.forward() to JSP. And then, JSP use
Request.getContextPath() to generate URLs (more precisely, getContextPath()
used by JSTL`s <c:url ..> implementation). 
But getContextPath() returns "/", so urls generated by <c:url> looks like
"//image/blah.gif" - i.e. they have double leading slashes. As result -
browser can`t process urls correctly. As I understand specification,
getContextPath() should returns empty string in such case... (And JSTL`s
implementation  of <c:url> expects such behavior).

If I deploy application under "ordinal" context path, all works correctly
(getContextPath() returns string like "/myapp").
If my Servlet use RD.include() instead of forward(), all works fine:
getContextPath() returns empty string.

Could somebody help me with solution.

Thanks.

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


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message