Status: New
Owner: ----

New issue 560 by nicolas.antoniazzi: RequestDispatcher forward fail if served page is the the welcome file
http://code.google.com/p/google-guice/issues/detail?id=560

If I want that my welcome file be a servlet that forward its rendering to a jsp page, the process crashes in com.google.inject.servlet.ServletDefinition$2.getPathInfo(ServletDefinition.java:206)

with :

java.lang.StringIndexOutOfBoundsException: String index out of range: -9
        at java.lang.String.substring(String.java:1937)
        at java.lang.String.substring(String.java:1904)
at com.google.inject.servlet.ServletDefinition$2.getPathInfo(ServletDefinition.java:206) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:359) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302) at com.cartser.metrics.server.core.servlet.GwtServlet.doLoad(GwtServlet.java:89) at com.cartser.metrics.server.core.servlet.GwtServlet.doGet(GwtServlet.java:94)

...

The problem is coming from a substring operation in getPathInfo()


  final int servletPathLength = getServletPath().length();
pathInfo = getRequestURI().substring(getContextPath().length()).replaceAll("[/]{2,}", "/").substring(servletPathLength);

  in my case :
getServletPath() = /index.jsp
getContextPath() = /myApp
getRequestURI() = /myApp (and not /myApp/index.jsp since index.jsp is declared as the default welcome file)
servletPathLength = 10

so when executing the substring operation with my URI :
getRequestURI().substring(getContextPath().length()).replaceAll("[/]{2,}", "/") ==> "/"
and "/".substring(10) ==> Exception.

Maybe that a check could be added on the length before executing the second substring() operation.

--
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice-dev?hl=en.

Reply via email to