URLs
Resin 3.0

Features
Installation
Configuration
Web Applications
IOC/AOP
Resources
JSP
Servlets and Filters
Portlets
Databases
Admin (JMX)
CMP
EJB
Amber
EJB 3.0
Security
XML and XSLT
XTP
JMS
Performance
Protocols
Third-party
Troubleshooting/FAQ

Introduction
JSP Compilation
Reference
Tutorials
Articles
FAQ

JSP Page Creation
Request
Topics
Tag Libraries

URL components
JSP environment
Form parameters
Multipart Forms
Headers
Request
Request
JSP environment

URLs

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&comment=7.

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


Request
Request
JSP environment
Copyright © 1998-2005 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.