Package org.apache.sling.api.wrappers

# Class SlingRequestPaths

java.lang.Object
org.apache.sling.api.wrappers.SlingRequestPaths

public class SlingRequestPaths extends Object
This class is not a "wrapper" per se, but computes the correct path info, request URI, etc. for included requests. When including a request via `RequestDispatcher`, the Servlet API specifies that target paths of the included request are available as request attributes. `Request.getPathInfo()`, for example will return the value for the including request, *not* for the included one.

This class is not intended to be extended or instantiated because it just provides constants and static utility methods not intended to be overwritten.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`INCLUDE_CONTEXT_PATH`
Deprecated.
Use `RequestDispatcher.INCLUDE_CONTEXT_PATH`
`static final String`
`INCLUDE_PATH_INFO`
Deprecated.
Use `RequestDispatcher.INCLUDE_PATH_INFO`
`static final String`
`INCLUDE_QUERY_STRING`
Deprecated.
Use `RequestDispatcher.INCLUDE_QUERY_STRING`
`static final String`
`INCLUDE_REQUEST_URI`
Deprecated.
Use `RequestDispatcher.INCLUDE_REQUEST_URI`
`static final String`
`INCLUDE_SERVLET_PATH`
Deprecated.
Use `RequestDispatcher.INCLUDE_SERVLET_PATH`

## Constructor Summary

Constructors
Constructor
Description
`SlingRequestPaths()`

## Method Summary

Modifier and Type
Method
Description
`static String`
`getContextPath(jakarta.servlet.http.HttpServletRequest r)`
Return the context path for r, using the appropriate request attribute if the request is an included one.
`static String`
`getContextPath(javax.servlet.http.HttpServletRequest r)`
Deprecated.
Use `getContextPath(HttpServletRequest)`
`static String`
`getPathInfo(jakarta.servlet.http.HttpServletRequest r)`
Return the context path for r, using the appropriate request attribute if the request is an included one.
`static String`
`getPathInfo(javax.servlet.http.HttpServletRequest r)`
Deprecated.
Use `getPathInfo(HttpServletRequest)`
`static String`
`getQueryString(jakarta.servlet.http.HttpServletRequest r)`
Return the query string for r, using the appropriate request attribute if the request is an included one.
`static String`
`getQueryString(javax.servlet.http.HttpServletRequest r)`
Deprecated.
Use `getQueryString(HttpServletRequest)`
`static String`
`getRequestURI(jakarta.servlet.http.HttpServletRequest r)`
Return the request URI for r, using the appropriate request attribute if the request is an included one.
`static String`
`getRequestURI(javax.servlet.http.HttpServletRequest r)`
Deprecated.
Use `getRequestURI(HttpServletRequest)`
`static String`
`getServletPath(jakarta.servlet.http.HttpServletRequest r)`
Return the servlet path for r, using the appropriate request attribute if the request is an included one.
`static String`
`getServletPath(javax.servlet.http.HttpServletRequest r)`
Deprecated.
Use `getServletPath(HttpServletRequest)`
`static boolean`
`isIncluded(jakarta.servlet.http.HttpServletRequest r)`
True if r is an included request, in which case it has the INCLUDE_REQUEST_URI attribute
`static boolean`
`isIncluded(javax.servlet.http.HttpServletRequest r)`
Deprecated.
Use `isIncluded(HttpServletRequest)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### INCLUDE_CONTEXT_PATH

@Deprecated public static final String INCLUDE_CONTEXT_PATH
Deprecated.
Use `RequestDispatcher.INCLUDE_CONTEXT_PATH`
Attribute name used by the RequestDispatcher to indicate the context path of the included request, as a String.

See Also:
  - Constant Field Values

### INCLUDE_PATH_INFO

@Deprecated public static final String INCLUDE_PATH_INFO
Deprecated.
Use `RequestDispatcher.INCLUDE_PATH_INFO`
Attribute name used by the RequestDispatcher to indicate the path info of the included request, as a String.

See Also:
  - Constant Field Values

### INCLUDE_QUERY_STRING

@Deprecated public static final String INCLUDE_QUERY_STRING
Deprecated.
Use `RequestDispatcher.INCLUDE_QUERY_STRING`
Attribute name used by the RequestDispatcher to indicate the query string of the included request, as a String.

See Also:
  - Constant Field Values

### INCLUDE_REQUEST_URI

@Deprecated public static final String INCLUDE_REQUEST_URI
Deprecated.
Use `RequestDispatcher.INCLUDE_REQUEST_URI`
Attribute name used by the RequestDispatcher to indicate the request URI of the included request, as a String.

See Also:
  - Constant Field Values

### INCLUDE_SERVLET_PATH

@Deprecated public static final String INCLUDE_SERVLET_PATH
Deprecated.
Use `RequestDispatcher.INCLUDE_SERVLET_PATH`
Attribute name used by the RequestDispatcher to indicate the servlet path of the included request, as a String.

See Also:
  - Constant Field Values

## Constructor Details

### SlingRequestPaths

public SlingRequestPaths()

## Method Details

### getContextPath

public static String getContextPath(jakarta.servlet.http.HttpServletRequest r)
Return the context path for r, using the appropriate request attribute if the request is an included one.

Parameters:
  `r` - The request
Returns:
  The context path.

### getPathInfo

public static String getPathInfo(jakarta.servlet.http.HttpServletRequest r)
Return the context path for r, using the appropriate request attribute if the request is an included one.

Parameters:
  `r` - The request
Returns:
  The path info.

### getQueryString

public static String getQueryString(jakarta.servlet.http.HttpServletRequest r)
Return the query string for r, using the appropriate request attribute if the request is an included one.

Parameters:
  `r` - The request
Returns:
  The query string.

### getRequestURI

public static String getRequestURI(jakarta.servlet.http.HttpServletRequest r)
Return the request URI for r, using the appropriate request attribute if the request is an included one.

Parameters:
  `r` - The request
Returns:
  The request uri.

### getServletPath

public static String getServletPath(jakarta.servlet.http.HttpServletRequest r)
Return the servlet path for r, using the appropriate request attribute if the request is an included one.

Parameters:
  `r` - The request
Returns:
  The servlet path.

### isIncluded

public static boolean isIncluded(jakarta.servlet.http.HttpServletRequest r)
True if r is an included request, in which case it has the INCLUDE_REQUEST_URI attribute

Parameters:
  `r` - The request
Returns:
  `true` if this is an include.

### getContextPath

@Deprecated public static String getContextPath(javax.servlet.http.HttpServletRequest r)
Deprecated.
Use `getContextPath(HttpServletRequest)`
Return the context path for r, using the appropriate request attribute if the request is an included one.

Parameters:
  `r` - The request
Returns:
  The context path.

### getPathInfo

@Deprecated public static String getPathInfo(javax.servlet.http.HttpServletRequest r)
Deprecated.
Use `getPathInfo(HttpServletRequest)`
Return the context path for r, using the appropriate request attribute if the request is an included one.

Parameters:
  `r` - The request
Returns:
  The path info.

### getQueryString

@Deprecated public static String getQueryString(javax.servlet.http.HttpServletRequest r)
Deprecated.
Use `getQueryString(HttpServletRequest)`
Return the query string for r, using the appropriate request attribute if the request is an included one.

Parameters:
  `r` - The request
Returns:
  The query string.

### getRequestURI

@Deprecated public static String getRequestURI(javax.servlet.http.HttpServletRequest r)
Deprecated.
Use `getRequestURI(HttpServletRequest)`
Return the request URI for r, using the appropriate request attribute if the request is an included one.

Parameters:
  `r` - The request
Returns:
  The request uri.

### getServletPath

@Deprecated public static String getServletPath(javax.servlet.http.HttpServletRequest r)
Deprecated.
Use `getServletPath(HttpServletRequest)`
Return the servlet path for r, using the appropriate request attribute if the request is an included one.

Parameters:
  `r` - The request
Returns:
  The servlet path.

### isIncluded

@Deprecated public static boolean isIncluded(javax.servlet.http.HttpServletRequest r)
Deprecated.
Use `isIncluded(HttpServletRequest)`
True if r is an included request, in which case it has the INCLUDE_REQUEST_URI attribute

Parameters:
  `r` - The request
Returns:
  `true` if this is an include.