This works well for me. See JavaDox at http://virtualschool.edu/jwaa
for the classes mentioned here.

        void doRequest(HttpServletRequest request,
HttpServletResponse response)
        {
00071     Ctx ctx = new Ctx(this, request, response);
00072     logRequest(ctx);
00073     try
00074     {
00075       String pageName = request.getPathInfo();
00076       if (pageName != null)
00077       {
00078         int lastSlash = pageName.lastIndexOf("/");
00079         if (lastSlash > -1)
00080           pageName = pageName.substring(lastSlash+1, pageName.length());
00081       }
00082       AbstractPage page = getDefaultPage().findPage(ctx, pageName);
00083       page.doRequest(ctx);
00084     }
00085     catch (Exception e) { fault(ctx, e); }
00086     finally
00087     {
00088       ctx.finalize();
00089     }
00090   }

getDefaultPage() is the page to be displayed if the page lookup fails.
Its findPage() method returns the looked up page if found, else itself.

At 6:26 AM -0700 7/14/01, t t wrote:
>Hi Folks
>
>I have just started writting Servlets and want advice
>on how to write a handler for all incoming requests.
>At the moment I have all requests going to the same
>servlet.  This servlet grabs a hidden variable which
>says which page the client is requesting, ie
>
>requestPage=mainMenu
>
>the servlet then looks at this variable in a big
>if/else block and determines what the user wants to do
>and then calls the appropriate handler for this
>request.  This looks messy to me and I want to know
>how other people tackle the problem.  Can someone
>please give me some insight into other ways of
>writting this main handler.
>
>
>
>
>Cheers
>
>Tony
>
>
>__________________________________________________
>Do You Yahoo!?
>Get personalized email addresses from Yahoo! Mail
>http://personal.mail.yahoo.com/
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html


--
For industrial age goods there were checks and credit cards.
For everything else there is mybank.dom at http://virtualschool.edu/mybank
Brad Cox, PhD; [EMAIL PROTECTED] 703 361 4751

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to