Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
-
Win XP , JDK 1.4.2
Description
from Java:
sc.getRequestDispatcher("someGroovlet.groovy").include(request,response);
or from jsp:
<jsp:include page="someGroovlet.groovy"/>
For a request with different URI then someGroovlet.xxx will throw exception :
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
java.lang.String.substring(String.java:1444)
groovy.servlet.GroovyServlet.getGroovyScriptPath(GroovyServlet.java:267)
groovy.servlet.GroovyServlet.service(GroovyServlet.java:192)
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
org.apache.jsp.index_jsp._jspService(index_jsp.java:53)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
(Try for / content including groovlet in index.jsp )
One proposal to resolve this according to Servlet 2.2 spec would be following patch in org.groovy.GroovyServlet.getGroovyScriptPath(HttpServletRequest) :
String strURI = null;
String includeURI = (String)request.getAttribute("javax.servlet.include.request_uri");
if (includeURI != null)
else
{ strURI = request.getRequestURI(); }// Get the name of the Groovy script
int contextLength = request.getContextPath().length();
String scriptFilename = strURI
.substring(contextLength).substring(1);
instead of :
// Get the name of the Groovy script
int contextLength = request.getContextPath().length();
String scriptFilename = request.getRequestURI()
.substring(contextLength).substring(1);
Attachments
Issue Links
- depends upon
-
GROOVY-814 Groovy TemplateServlet NPE fixed and totally revamped
- Closed