tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <>
Subject RE: Traversing up a directory using RequestDispatcher
Date Fri, 17 Sep 2004 12:17:07 GMT

First of all, Xeth is the best name I've seen in a long time -- cool!

>I have a bizarre issue.  Using Tomcat 5.0.12, I have an application in
>the directory C:\jakarta-tomcat-5.0.12\webapps called ChargeCard.
>After loggin in, I am trying to forward a request to jsp page in that
>directory.  However, RequestDispatcher apparently uses the directory
>C:\jakarta-tomcat-5.0.12\webapps\ROOT as the Document root, so I need
>to go up a directory in my forward request (something like url =
>"../ChargeCard/index.jsp";)  However, RequestDispatcher requires a /
>to start off the url, so I can't use the ../ start to go up a
>directory.  Does anyone have an idea how I would do this?  I tried url
>= "/../ChargeCard/index.jsp";, but that results in a
>NullPointerException being thrown.  All help is appreciated!

The RequestDispatcher's behavior is constrained by the Servlet
Specification.  Its JavaDoc has an explanation on how it resolves
relative links: the leading slash for the getRequestDispatcher call is
not really absolute, it's relative to the webapp's docBase.

There's no reason Tomcat would use ROOT as the docBase, unless you're
actually in the root webapp.  What is the docBase for your webapp?
(Hint: it's not c:\jakarta-tomcat-5.0.12\webapps, it's a subdirectory
under it, unless you've explicitly defined a Context with the webapp
docBase) (in which case, if you kept the default Host appBase, you have
a bad configuration).


This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message