You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2017/03/20 20:59:03 UTC
[20/48] wicket git commit: WicketWICKET-6328 Add 'pathInfo' to
ForwardAttributes
WicketWICKET-6328 Add 'pathInfo' to ForwardAttributes
Use RequestDispatcher constants to refer to the attributes
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/13613266
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/13613266
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/13613266
Branch: refs/heads/master
Commit: 13613266739a8e105b9e30c184e7bc9a1258cb45
Parents: 166bea1
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon Feb 27 09:06:12 2017 +0100
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Mon Mar 20 21:42:32 2017 +0100
----------------------------------------------------------------------
.../protocol/http/servlet/ErrorAttributes.java | 27 +++++------
.../http/servlet/ForwardAttributes.java | 48 +++++++++++++-------
2 files changed, 45 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/13613266/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ErrorAttributes.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ErrorAttributes.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ErrorAttributes.java
index 874af09..390fa56 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ErrorAttributes.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ErrorAttributes.java
@@ -16,6 +16,7 @@
*/
package org.apache.wicket.protocol.http.servlet;
+import javax.servlet.RequestDispatcher;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
@@ -23,18 +24,18 @@ import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.string.Strings;
/**
- * Represents additional error parameters present in a {@link ServletRequest} when the servlet
+ * Represents additional error attributes present in a {@link ServletRequest} when the servlet
* container is handling an error or a forward to an error page mapped by {@code error-page} element
* in {@code web.xml}.
*
* See documentation for the following request attributes for the values stored in this object:
* <ul>
- * <li>javax.servlet.error.status_code</li>
- * <li>javax.servlet.error.message</li>
- * <li>javax.servlet.error.request_uri</li>
- * <li>javax.servlet.error.servlet_name</li>
- * <li>javax.servlet.error.exception_type</li>
- * <li>javax.servlet.error.exception</li>
+ * <li>{@link RequestDispatcher#ERROR_STATUS_CODE}</li>
+ * <li>{@link RequestDispatcher#ERROR_MESSAGE}</li>
+ * <li>{@link RequestDispatcher#ERROR_REQUEST_URI}</li>
+ * <li>{@link RequestDispatcher#ERROR_SERVLET_NAME}</li>
+ * <li>{@link RequestDispatcher#ERROR_EXCEPTION_TYPE}</li>
+ * <li>{@link RequestDispatcher#ERROR_EXCEPTION}</li>
* </ul>
*
* @author igor
@@ -144,13 +145,13 @@ public class ErrorAttributes
public static ErrorAttributes of(HttpServletRequest request, String filterPrefix)
{
Args.notNull(request, "request");
- Integer code = (Integer)request.getAttribute("javax.servlet.error.status_code");
- String message = (String)request.getAttribute("javax.servlet.error.message");
- String uri = DispatchedRequestUtils.getRequestUri(request, "javax.servlet.error.request_uri", filterPrefix);
- String servlet = (String)request.getAttribute("javax.servlet.error.servlet_name");
+ Integer code = (Integer)request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
+ String message = (String)request.getAttribute(RequestDispatcher.ERROR_MESSAGE);
+ String uri = DispatchedRequestUtils.getRequestUri(request, RequestDispatcher.ERROR_REQUEST_URI, filterPrefix);
+ String servlet = (String)request.getAttribute(RequestDispatcher.ERROR_SERVLET_NAME);
@SuppressWarnings("unchecked")
- Class<? extends Throwable> type = (Class<? extends Throwable>)request.getAttribute("javax.servlet.error.exception_type");
- Throwable ex = (Throwable)request.getAttribute("javax.servlet.error.exception");
+ Class<? extends Throwable> type = (Class<? extends Throwable>)request.getAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE);
+ Throwable ex = (Throwable)request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
if (!Strings.isEmpty(uri) || code != null || ex != null)
{
http://git-wip-us.apache.org/repos/asf/wicket/blob/13613266/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ForwardAttributes.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ForwardAttributes.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ForwardAttributes.java
index 9741b32..5950468 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ForwardAttributes.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ForwardAttributes.java
@@ -16,6 +16,7 @@
*/
package org.apache.wicket.protocol.http.servlet;
+import javax.servlet.RequestDispatcher;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
@@ -23,18 +24,16 @@ import org.apache.wicket.util.lang.Args;
import org.apache.wicket.util.string.Strings;
/**
- * Represents additional error parameters present in a {@link ServletRequest} when the servlet
- * container is handling an error or a forward to an error page mapped by {@code error-page} element
- * in {@code web.xml}.
+ * Represents additional attributes present in a {@link ServletRequest} when the servlet
+ * container is handling a forward to another path than the initially requested one.
*
* See documentation for the following request attributes for the values stored in this object:
* <ul>
- * <li>javax.servlet.error.status_code</li>
- * <li>javax.servlet.error.message</li>
- * <li>javax.servlet.error.request_uri</li>
- * <li>javax.servlet.error.servlet_name</li>
- * <li>javax.servlet.error.exception_type</li>
- * <li>javax.servlet.error.exception</li>
+ * <li>{@link javax.servlet.RequestDispatcher#FORWARD_CONTEXT_PATH}</li>
+ * <li>{@link javax.servlet.RequestDispatcher#FORWARD_PATH_INFO}</li>
+ * <li>{@link javax.servlet.RequestDispatcher#FORWARD_QUERY_STRING}</li>
+ * <li>{@link javax.servlet.RequestDispatcher#FORWARD_REQUEST_URI}</li>
+ * <li>{@link javax.servlet.RequestDispatcher#FORWARD_SERVLET_PATH}</li>
* </ul>
*
*/
@@ -52,6 +51,9 @@ public class ForwardAttributes
// javax.servlet.forward.query_string
private final String queryString;
+ // javax.servlet.forward.path_info
+ private final String pathInfo;
+
/**
* Constructor.
*
@@ -59,14 +61,16 @@ public class ForwardAttributes
* @param servletPath
* @param contextPath
* @param queryString
+ * @param pathInfo
*/
private ForwardAttributes(String requestUri, String servletPath, String contextPath,
- String queryString)
+ String queryString, String pathInfo)
{
this.requestUri = requestUri;
this.servletPath = servletPath;
this.contextPath = contextPath;
this.queryString = queryString;
+ this.pathInfo = pathInfo;
}
/**
@@ -110,6 +114,13 @@ public class ForwardAttributes
}
/**
+ * @return the path info of the request before the forward dispatch
+ */
+ public String getPathInfo() {
+ return pathInfo;
+ }
+
+ /**
* Factory for creating instances of this class.
*
* @param request
@@ -119,15 +130,17 @@ public class ForwardAttributes
{
Args.notNull(request, "request");
- final String requestUri = DispatchedRequestUtils.getRequestUri(request, "javax.servlet.forward.request_uri", filterPrefix);
- final String servletPath = (String)request.getAttribute("javax.servlet.forward.servlet_path");
- final String contextPath = (String)request.getAttribute("javax.servlet.forward.context_path");
- final String queryString = (String)request.getAttribute("javax.servlet.forward.query_string");
+ final String requestUri = DispatchedRequestUtils.getRequestUri(request, RequestDispatcher.FORWARD_REQUEST_URI, filterPrefix);
+ final String servletPath = (String)request.getAttribute(RequestDispatcher.FORWARD_SERVLET_PATH);
+ final String contextPath = (String)request.getAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH);
+ final String queryString = (String)request.getAttribute(RequestDispatcher.FORWARD_QUERY_STRING);
+ final String pathInfo = (String)request.getAttribute(RequestDispatcher.FORWARD_PATH_INFO);
if (!Strings.isEmpty(requestUri) || !Strings.isEmpty(servletPath) ||
- !Strings.isEmpty(contextPath) || !Strings.isEmpty(queryString))
+ !Strings.isEmpty(contextPath) || !Strings.isEmpty(queryString) ||
+ !Strings.isEmpty(pathInfo))
{
- return new ForwardAttributes(requestUri, servletPath, contextPath, queryString);
+ return new ForwardAttributes(requestUri, servletPath, contextPath, queryString, pathInfo);
}
return null;
}
@@ -136,6 +149,7 @@ public class ForwardAttributes
public String toString()
{
return "ForwardAttributes [requestUri=" + requestUri + ", servletPath=" + servletPath +
- ", contextPath=" + contextPath + ", queryString=" + queryString + "]";
+ ", contextPath=" + contextPath + ", queryString=" + queryString +
+ ", pathInfo=" + pathInfo + "]";
}
}