From 385298b808e13a2d1b32a94f3660374a4f3dc9c9 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 12 Apr 2010 14:59:27 +0000 Subject: [PATCH] JSP FormTag calculates proper default form action even when using a rewrite filter on WebSphere (SPR-7067) --- .../web/util/UrlPathHelper.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/org.springframework.web/src/main/java/org/springframework/web/util/UrlPathHelper.java b/org.springframework.web/src/main/java/org/springframework/web/util/UrlPathHelper.java index 622566d9943..1a83301399f 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/util/UrlPathHelper.java +++ b/org.springframework.web/src/main/java/org/springframework/web/util/UrlPathHelper.java @@ -40,6 +40,14 @@ import org.springframework.util.StringUtils; */ public class UrlPathHelper { + /** + * Special WebSphere request attribute, indicating the original request URI. + * Preferable over the standard Servlet 2.4 forward attribute on WebSphere, + * simply because we need the very first URI in the request forwarding chain. + */ + private static final String WEBSPHERE_URI_ATTRIBUTE = "com.ibm.websphere.servlet.uri_non_decoded"; + + private final Log logger = LogFactory.getLog(getClass()); private boolean alwaysUseFullPath = false; @@ -236,13 +244,14 @@ public class UrlPathHelper { /** * Return the request URI for the given request. If this is a forwarded request, * correctly resolves to the request URI of the original request. - *

Relies on the Servlet 2.4 'forward' attributes. These attributes may be set by - * other components when running in a Servlet 2.3 environment. */ public String getOriginatingRequestUri(HttpServletRequest request) { - String uri = (String) request.getAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE); + String uri = (String) request.getAttribute(WEBSPHERE_URI_ATTRIBUTE); if (uri == null) { - uri = request.getRequestURI(); + uri = (String) request.getAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE); + if (uri == null) { + uri = request.getRequestURI(); + } } return decodeAndCleanUriString(request, uri); } @@ -252,8 +261,6 @@ public class UrlPathHelper { * URL if called within a RequestDispatcher include. *

As the value returned by request.getContextPath() is not * decoded by the servlet container, this method will decode it. - *

Relies on the Servlet 2.4 'forward' attributes. These attributes may be set by - * other components when running in a Servlet 2.3 environment. * @param request current HTTP request * @return the context path */