You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Craig R. McClanahan" <Cr...@eng.sun.com> on 2001/03/02 21:05:19 UTC

Re: Calling within and across webapp contexts

Rick Herrick wrote:

> I asked the question earlier and never received a response, so I'll try again!
>
> We have a JSP app that's currently running in JRun 2.3.3 (JSP 1.0
> compliant).  When we refer to different directories within the app, we
> always preface with the "context" name, or really the top-level virtual
> directory.  So if you want a common file, you do this:
>
> <jsp:forward page = "/CpsAdmin/Common/loginForm.jsp" />
>
> The problem is that, testing under Tomcat, this doesn't work.  It tries to
> prepend the context name onto the path, so that this becomes
> /CpsAdmin/CpsAdmin/Common/loginForm.jsp.
>
> My questions are:
>
> * Is this part of the JSP 1.1 spec?  It flies in the face of conventional
> usage of path names across the board, i.e. anything that starts with '/'
> means you go to the top-level of the server hierarchy.  What's the rationale?
>

Yes.  It was also true for JSP 1.0, so it looks like JRun implemented this wrong
if it behaves the way you describe.

The path you give to <jsp:forward> or <jsp:include> is supposed to be the
context-relative path of the file you want to forward to or include.  So, for your
case above, it should be:

    <jsp:forward page="/Common/loginForm.jsp"/>


> * Is there anyway to change this and make Tomcat do the "right" thing, i.e.
> see '/' as the server root?
>

Nope ... Tomcat is already doing the "right" thing by the specs.  To see for
yourself:

    http://java.sun.com/products/jsp/download.html

>
> * Does this also mean that you can't call across contexts?  That is, we
> produce our tools as separate items, since customers may install some
> pieces and not others.  But if two tools are installed, they can work
> together and then would need to call across contexts.  I can think of no
> good reason why this shouldn't be permitted, but based on this behavior, it
> does look as if it would.
>

That is a correct inference.  You cannot do a <jsp:forward> or <jsp:include>
across web applications.

The rationale behind all of this is:
* Web apps are supposed to be independent
* Your system administrator should be able to deploy your
  web app on any context path, and it should still work

>
> Thanks in advance for any feedback!  Getting this worked out will help save
> me a TON of time porting over our apps!
>
> Rick Herrick, AKA rick@violetshivers.com
> In zero gravity, nothing is amusing.
> PGP: http://www.rickherrick.com/pgpkey
>

Craig McClanahan