Drew Nichols wrote:
>
> Hi,
> I use a JSP to implement a simple redirect.
> Code looks like this
>
> <%@page contentType="text/html"
>         errorPage="publicError.jsp"%>
> <%
>     String forward = request.getParameter ("page");
> %>
> <jsp:forward page="<%= forward %>" />
>
> If the "page" happens to reference a file out of the same directory as the
> jsp all the links are incorrect. The "page"s are all relative links eg.
> "booking/publicBooking.jsp"
> If I use absolute links eg "/booking/publicBooking.jsp" the same thing
> happens.
>
> Any clues??

The page path can be either "page-relative" (a path that doesn't start
with a slash) or "context-relative" (a path that starts with a slash).

So, using your examples, "booking/publicBooking.jsp" is a page-relative
path. It should work if you have a directory named "booking" in the
same directory as the JSP page that contains the <jsp:forward> action,
and if there's a file named "publicBooking.jsp" in the "booking"
directory.

If you use "/booking/publicBooking.jsp", your web application must
have a directory at the root named "booking", with a file named
"publicBooking.jsp". Note that if "/booking" is the context prefix
you have associated with your web application, you should *not*
include it in the path. That's why this is called a context-relative
path, and it's key to being able to install the application using
any context prefix.

If the JSP page with the <jsp:forward> action is in the same
directory as the publicBooking.jsp file, just use the file name,
i.e. page="publicBooking.jsp"

This is covered in detail in my JSP book. For details, see:

  <http://TheJSPBook.com/>

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to