|
|
 |

The request
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.
Some reasons you may need to look at the URL information:
- form submission
- selecting sections of a manual
- displaying different stories on a news site
- displaying comments on a discussion group
- sort preferences for the discussion site
- search results
RequestURI
getRequestURI() returns the full path, excluding any query string.
ServletPath
getServletPath() returns the URI prefix that matches the
servlet. In the case of a JSP, it will return everything up to the
*.jsp.
The servlet path is useful for servlets like JSP, XTP, or SSI that
read and transform files.
PathInfo
getPathInfo() returns everything after the ServletPath.
A discussion board servlet could use PathInfo to select stories
and comments.
QueryString
getQueryString() returns the query string, everything after the
'?'
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 /comment.xtp?story=15&comment7.
http://localhost:8080/test/env.jsp/tail?a=b
|
env.jsp
<table> <tr><td>URI <td><%= request.getRequestURI() %> <tr><td>ServletPath <td><%= request.getServletPath() %> <tr><td>PathInfo <td><%= request.getPathInfo() %> <tr><td>QueryString <td><%= request.getQueryString() %> <tr><td>a <td><%= request.getParameter("a") %> </table>
|
URI /test/env.jsp/tail ServletPath /test/env.jsp PathInfo /tail QueryString a=b a b
|
Copyright © 1998-2001 Caucho Technology. All rights reserved.
Copyright © 1998-2001 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark,
and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.
|
 |
|