Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Signup Challenge at MyJavaServer

807605Aug 13 2007 — edited Aug 13 2007
Hi. For those that have been at http://www.myjavaserver.com/signup there is a signup challenge before one gets an account. I just have a question though, what exactly is the question here? The following is what appears there:
 
...
In order to minimize abuse and yet provide our services to all interested Java developers for free, we require you to demonstrate your Java skills. The challenge is easy to master but does require some knowledge of the Java programming language.

Signup Challenge
Master a simple Java programming challenge

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(String[] 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, "pqGaUH" must be returned.

Example input:

  String[] config: { "/", "MainServlet", "/nav", "NavigationServlet" }
  String requestUri: "/nav/test"

  Correct result: "NavigationServlet"

In this example, the configuration contains a mapping of "/" to "MainServlet" and "/nav" to "NavigationServlet". In the case of an incoming URI "/nav/test.nav", "NavigationServlet" is the correct choice because its pattern is longer than that of "MainServlet".
...
After that there is a space for you to enter code. What is the question here?

Thank you.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 10 2007
Added on Aug 13 2007
16 comments
101 views