You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Jonathan Gray <jo...@f-i.com> on 2010/09/29 16:52:19 UTC
ServletWebRequest throwing StringIndexOutOfBounds exception when
upgrading from 1.4.10 - 1.4.12
hello - we were trying to upgrade from wicket 1.4.10 to wicket 1.4.12
and ran into a problem in the ServletWebRequest class. the old code
was:
HttpServletRequest httpRequest = getHttpServletRequest();
// This is in the Servlet 2.3 spec giving us the URI of the
resource
// that caused the error. Unfortunately, this includes the
context path.
String errorUrl =
(String)httpRequest.getAttribute("javax.servlet.error.request_uri");
// This gives us a context-relative path for
RequestDispatcher.forward
// stuff, with a leading slash.
String forwardUrl =
(String)httpRequest.getAttribute("javax.servlet.forward.servlet_path");
if (forwardUrl != null && forwardUrl.length() > 0)
{
// If this is an error page, this will be /mount or
/?wicket:foo
relativeUrl = forwardUrl.substring(1);
}
and the new code is:
HttpServletRequest httpRequest = getHttpServletRequest();
// This is in the Servlet 2.3 spec giving us the URI of the
resource
// that caused the error. Unfortunately, this includes the
context path.
String errorUrl =
(String)httpRequest.getAttribute("javax.servlet.error.request_uri");
// This gives us a context-relative path for
RequestDispatcher.forward
// stuff, with a leading slash.
String forwardUrl =
(String)httpRequest.getAttribute("javax.servlet.forward.servlet_path");
final String filterPath =
(String)httpServletRequest.getAttribute(WicketFilter.FILTER_PATH_ATTR);
if (!Strings.isEmpty(forwardUrl))
{
// If this is an error page, this will be /mount or
/?wicket:foo
relativeUrl = forwardUrl.substring(1);
relativeUrl =
relativeUrl.substring(filterPath.length());
}
there is a new filterPath String that is used in the if statement to
derive a substring from the forwardUrl. problem is, my forwardUrl is
/rw and my filter path is /wicket and the substring function fails
with a StringIndexOutOfBounds exception. can someone tell me what the
purpose of this change was and why it might be breaking now? thanks
in advance for your input!
- jon
Re: ServletWebRequest throwing StringIndexOutOfBounds exception when
upgrading from 1.4.10 - 1.4.12
Posted by Igor Vaynberg <ig...@gmail.com>.
there are two issues that were fixed and relate to the code:
WICKET-1887 and WICKET-2712, in both cases relative urls were not
calculated correctly. the code there now fixes that. please open a new
issue and attach a quickstart.
-igor
On Wed, Sep 29, 2010 at 7:52 AM, Jonathan Gray <jo...@f-i.com> wrote:
> hello - we were trying to upgrade from wicket 1.4.10 to wicket 1.4.12
> and ran into a problem in the ServletWebRequest class. the old code
> was:
>
> HttpServletRequest httpRequest = getHttpServletRequest();
>
> // This is in the Servlet 2.3 spec giving us the URI of the
> resource
> // that caused the error. Unfortunately, this includes the
> context path.
> String errorUrl =
> (String)httpRequest.getAttribute("javax.servlet.error.request_uri");
>
> // This gives us a context-relative path for
> RequestDispatcher.forward
> // stuff, with a leading slash.
> String forwardUrl =
> (String)httpRequest.getAttribute("javax.servlet.forward.servlet_path");
>
> if (forwardUrl != null && forwardUrl.length() > 0)
> {
> // If this is an error page, this will be /mount or
> /?wicket:foo
> relativeUrl = forwardUrl.substring(1);
> }
>
> and the new code is:
>
> HttpServletRequest httpRequest = getHttpServletRequest();
>
> // This is in the Servlet 2.3 spec giving us the URI of the
> resource
> // that caused the error. Unfortunately, this includes the
> context path.
> String errorUrl =
> (String)httpRequest.getAttribute("javax.servlet.error.request_uri");
>
> // This gives us a context-relative path for
> RequestDispatcher.forward
> // stuff, with a leading slash.
> String forwardUrl =
> (String)httpRequest.getAttribute("javax.servlet.forward.servlet_path");
>
> final String filterPath =
> (String)httpServletRequest.getAttribute(WicketFilter.FILTER_PATH_ATTR);
>
> if (!Strings.isEmpty(forwardUrl))
> {
> // If this is an error page, this will be /mount or
> /?wicket:foo
> relativeUrl = forwardUrl.substring(1);
> relativeUrl =
> relativeUrl.substring(filterPath.length());
> }
>
> there is a new filterPath String that is used in the if statement to
> derive a substring from the forwardUrl. problem is, my forwardUrl is
> /rw and my filter path is /wicket and the substring function fails
> with a StringIndexOutOfBounds exception. can someone tell me what the
> purpose of this change was and why it might be breaking now? thanks
> in advance for your input!
>
> - jon
>