<title section="Resin : JSP Tutorial : Request : ">
URLs
</title>

The <a href="../javadoc/javax/servlet/http/HttpServletRequest.html">request</a>
object breaks down the request URL into components.  Servlets and JSP
pages can use those components to vary the response while using the
same servlet or JSP page.

<p/>Some reasons you may need to look at the URL information:
<ul>
<li>form submission
<li>selecting sections of a manual
<li>displaying different stories on a news site
<li>displaying comments on a discussion group
<li>sort preferences for the discussion site
<li>search results
</ul>

<subsection title="RequestURI">

<var/getRequestURI()/> returns the full path, excluding any query string.

</subsection>

<subsection title="ServletPath">

<var/getServletPath()/> returns the URI prefix that matches the
servlet.  In the case of a JSP, it will return everything up to the
*.jsp.

<p/>The servlet path is useful for servlets like JSP, XTP, or SSI that
read and transform files.

</subsection>

<subsection title="PathInfo">

<var/getPathInfo()/> returns everything after the ServletPath.

<p/>A discussion board servlet could use PathInfo to select stories
and comments.

</subsection>

<subsection title="QueryString">

<var/getQueryString()/> returns the query string, everything after the
'?'

<p/>Often, query strings are the result of form submissions but it's
also useful for database-driven sites.  For example, you might encode
"story 15, comment 7" of a discussion as <var//comment.xtp?story=15&comment=7/>.

</subsection>

<example>
http://localhost:8080/test/env.jsp/tail?a=b
</example>

<example title='env.jsp'>
<example>
&lt;table>
&lt;tr>&lt;td>URI         &lt;td>&lt;%= request.getRequestURI() %>
&lt;tr>&lt;td>ServletPath &lt;td>&lt;%= request.getServletPath() %>
&lt;tr>&lt;td>PathInfo    &lt;td>&lt;%= request.getPathInfo() %>
&lt;tr>&lt;td>QueryString &lt;td>&lt;%= request.getQueryString() %>
&lt;tr>&lt;td>a           &lt;td>&lt;%= request.getParameter("a") %>
&lt;/table>
</example>
<results>
URI          /test/env.jsp/tail
ServletPath  /test/env.jsp
PathInfo     /tail
QueryString  a=b
a            b
</results>
</example>
