You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Frans Stofberg (JIRA)" <ji...@apache.org> on 2011/03/08 09:28:59 UTC

[jira] Commented: (WICKET-3497) Request.getUrl() not returning correct data

    [ https://issues.apache.org/jira/browse/WICKET-3497?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13003855#comment-13003855 ] 

Frans Stofberg commented on WICKET-3497:
----------------------------------------

Okay, This is fine for my 1st point, but point nr.2 is still an issue.

If I have two filter mappings in web.xml, only the 1st one gets loaded on the servlet/filter startup. When calling request.getUrl() you get either an array index out of bounds exception or part of the filter mapping in the url when you access the app with the second mapping.

here is an example

2 mappings

/app/*
/longapp/*

when accessing with /app/ request.getUrl() works fine.
when accessing with /longapp/ request.getUrl() will return gapp/ (it takes the length of /app/ as the star for the substring)

-------ServletWebRequest.getUrl()--------------
...
final int start = request.getContextPath().length() + filterPrefix.length() + 1;
url.append(uri.substring(start));
...
-------------------------------------------------------------
filterPrefix was loaded on the startup of the filter, which in this case is /app/ (this is can not be correct)

you can see that if the mappings were reversed (/longapp/* before /app/*) in web.xml the above code will throw an array/string index out of bounds exception (and it does)

please have another look Igor

Thanks






> Request.getUrl() not returning correct data
> -------------------------------------------
>
>                 Key: WICKET-3497
>                 URL: https://issues.apache.org/jira/browse/WICKET-3497
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-core
>    Affects Versions: 1.5-RC2
>         Environment: Linux, Firefox, IBM WebSphere 6.1
>            Reporter: Frans Stofberg
>            Assignee: Igor Vaynberg
>         Attachments: getUrlTest.zip
>
>
> There are 2 parts to this issue
> assume 2 servlet mappings in web.xml
>  - /app/*
>  - /longapp/*
> 1. Calling Request.getUrl().toString() use to (v 1.4.x) return everything after the context root (eg app/somePage/). Now in 1.5 this only returns somePage
> 2. When multiple servlet mappings are specified in web.xml, only the first one is loaded on servlet/filter startup. This causes problems when accessing the app thru any of the mappings other than the first one.
> [11/03/03 11:58:50:507 SAST] 00000028 WebApp        E   [Servlet Error]-[wicket.getUrlTest]: java.lang.StringIndexOutOfBoundsException: String index out of range: 17
> 	at java.lang.String.substring(String.java:1067)
> 	at org.apache.wicket.protocol.http.servlet.ServletWebRequest.getUrl(ServletWebRequest.java:159)
> 	at org.apache.wicket.protocol.http.servlet.ServletWebRequest.<init>(ServletWebRequest.java:98)
> 	at org.apache.wicket.protocol.http.servlet.ServletWebRequest.<init>(ServletWebRequest.java:73)
> 	at org.apache.wicket.protocol.http.WebApplication.newWebRequest(WebApplication.java:384)
> 	at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:133)
> 	at org.apache.wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:137)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira