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

Provide an alternative implementation of GroovyServlet to a allow a single groovlet handle multiple urls, through, a mapping of regular expressions to groovy scripts.

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.5.7
    • None
    • Groovlet / GSP
    • None

    Description

      The current implementation of GroovyServlet is similar to a cgi-bin where the requested url contains the path to a groovy script that renders an individual page. This is very limiting as it requires a one to one relationship to url destination and groovy script. There are many cases where a single groovlet could handle multiple urls. I've attachted a proof of concept implementation of the feature as UrlMappingGroovyServlet. On initialization it loads a properties file into an internal map the key being the regular expression to be matched against the url and the value being the path to the script that can handle that url. When a request comes in, the servlet iterates over the entries of the hash map finding the first pattern (key) that matches the requested url it then delegates to that script for handling of the request.

      An example mapping file has been attached as map.properties. That is the default name for the map file, this can be customized through an init-param.

      Attachments

        1. map.properties
          0.0 kB
          Stephen Solka
        2. UrlMappingGroovyServlet.java
          3 kB
          Stephen Solka

        Activity

          People

            Unassigned Unassigned
            trashhalo Stephen Solka
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: