Please Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shanaj
    New Member
    • Jan 2007
    • 51

    #1

    Please Help

    As the principal engineer of an HTTP web server, you are responsible for implementing the request processing subsystem of the server.
    An incoming request for a specific resource, identified by an URI, must be dispatched to the appropriate handler according to the server configuration which maps URIs to request handlers. 'HandlerFactory .getHandler' must be implemented:

    public class HandlerFactory
    {
    public String getHandler(Stri ng[] config, String requestUri)
    {
    }
    }


    The string array 'config' contains URI patterns and handler names. Two consecutive values form a key-value pair comprised of URI pattern and handler. 'requestUri' represents an incoming request, the URI to match against the configured handlers. 'getHandler' must return the correct handler for a given URI as a string value.

    An URI pattern never contains wildcards and represents the start of an URI string, a prefix. Matching must be implemented accordingly. The handler with the longest matching URI pattern wins if more than one pattern matches. If no handler can be found, "emKqGeb" must be returned.

    Example input:

    String[] config: { "/", "MainServle t", "/nav", "NavigationServ let" }
    String requestUri: "/nav/test"

    Correct result: "NavigationServ let"

    In this example, the configuration contains a mapping of "/" to "MainServle t" and "/nav" to "NavigationServ let". In the case of an incoming URI "/nav/test.nav", "NavigationServ let" is the correct choice because its pattern is longer than that of "MainServle t".



    public class HandlerFactory
    {
    public String getHandler(Stri ng[] config, String requestUri)
    {
    ;
    }
    }
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by Shanaj
    As the principal engineer of an HTTP web server, you are responsible for implementing the request processing subsystem of the server.
    An incoming request for a specific resource, identified by an URI, must be dispatched to the appropriate handler according to the server configuration which maps URIs to request handlers. 'HandlerFactory .getHandler' must be implemented:

    public class HandlerFactory
    {
    public String getHandler(Stri ng[] config, String requestUri)
    {
    }
    }


    The string array 'config' contains URI patterns and handler names. Two consecutive values form a key-value pair comprised of URI pattern and handler. 'requestUri' represents an incoming request, the URI to match against the configured handlers. 'getHandler' must return the correct handler for a given URI as a string value.

    An URI pattern never contains wildcards and represents the start of an URI string, a prefix. Matching must be implemented accordingly. The handler with the longest matching URI pattern wins if more than one pattern matches. If no handler can be found, "emKqGeb" must be returned.

    Example input:

    String[] config: { "/", "MainServle t", "/nav", "NavigationServ let" }
    String requestUri: "/nav/test"

    Correct result: "NavigationServ let"

    In this example, the configuration contains a mapping of "/" to "MainServle t" and "/nav" to "NavigationServ let". In the case of an incoming URI "/nav/test.nav", "NavigationServ let" is the correct choice because its pattern is longer than that of "MainServle t".



    public class HandlerFactory
    {
    public String getHandler(Stri ng[] config, String requestUri)
    {
    ;
    }
    }
    And what is the question?

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Originally posted by r035198x
      And what is the question?
      I don't know but this looks very much like a homework assignment.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by acoder
        I don't know but this looks very much like a homework assignment.
        It certainly is. The OP better start early on it too rather than wait for someone to dump some code on them.

        Comment

        Working...