Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

Java Factory Handler

Thread view: 
ashishtiwari05@gmail.com - 20 Sep 2007 10:17 GMT
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, "6fgIiN" 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".

Could any body complete this code by taking account for above
information

public class HandlerFactory
{
 public String getHandler(String[] config, String requestUri)
 {
   ;
 }
}
kcwong - 20 Sep 2007 10:36 GMT
> As the principal engineer of an HTTP web server, you are responsible
> for implementing the request processing subsystem of the server.
[quoted text clipped - 46 lines]
>
> }

comp.lang.java.programmer is not for begging others to do your
homework.

Post what you have coded so far, and what *specific* questions you
have and what *specific* difficulties you're facing.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.