"Ng, Sei" wrote:
>
> Hi,
>
> I'm using the jsp:include tag to include a child page.
> Is that a way to get the parent uri from the child page?
>
> I've been trying all the day long. I don't think it is
> possible.  Please Help.

You can use request.getRequestURI() to get the complete URI used to invoke the
parent page, since no URI path information is changed when you include a page.
If you want the context/application-relative URI, use request.getServletPath()
instead. Context relative paths (i.e. the URI path minus the context's URI
prefix) must be used in <jsp:forward> and <jsp:include>, while a complete URI is
needed when you call sendRedirect().

If you use forward instead of include, the URI path information *is* changed
to that of the target JSP/servlet. You can still get the URI path info that
refers to the parent through a number of request attributes in the target JSP:

  javax.servlet.include.request_uri
  javax.servlet.include.context_path
  javax.servlet.include.servlet_path
  javax.servlet.include.path_info
  javax.servlet.include.query_string

All of this, and a lot more, is described in the Servlet 2.2 specification
available at <http://java.sun.com/products/servlet/index.html>. Do yourself
a favor and save a lot of time by reading both the JSP and the Servlet specs.
They actually tell you how things are supposed to work ;-)

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
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