Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-815

Include of groovlets does not work

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0-JSR-2
    • 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)

      { strURI = includeURI; }

      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

          Activity

            People

              sormuras sormuras
              boris Boris Schrijver
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 24h
                  24h
                  Remaining:
                  Remaining Estimate - 24h
                  24h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified