Tony LaPaso wrote:
Hello all,

May I ask a question?

I have a servlet named "FormDispatcher" which I include from a JSP like
this:

<jsp:include page="servlet/FormDispatcher/abc/def"/>

What I *want* is for the FormDispatcher servlet to be able to access the
"/abc/def" path info by calling "request.getPathInfo()".

When the servlet calls "request.getPathInfo()", however, the method returns
the path info for the JSP which contains the <jsp:include> element shown
above, not "/abc/def". I understand why this is and it makes perfect sense
to me. *BUT*, I'm hoping there is a way, somehow, for me to gain access to
the "/abc/def" path info.
[...]
In an resource (servlet or JSP page) included through the
RequestDispatcher (which is what <jsp:include> uses internally), the
URI info used to identify the included resource is available as a
set of request attributes:

  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

(see the Servlet 2.3 spec, section SRV.8.3.1 Included Request
Parameters, for details). So you can get the path info with a call
like this:

  String pathInfo =
    request.getAttribute("javax.servlet.include.path_info");

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com
JavaServer Pages        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://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com

Reply via email to