"Hines, Bill" wrote:

> Craig,
>
> I noticed here and in another message from you that when you do the
> getServletPath to get the "/listCustomers.do", you then strip off down to
> "listCustomers" and then search a hashtable to get the action class name,
> then search another hash table by that to get the class object itself. Why
> can't you just make the part before .do the action class name itself and
> save that extra step?
>

You can certainly do what you're suggesting (similar in philosophy to the idea of
using /servlet/xxxxx to execute a servlet in a class named xxxxx).  However,
consider the following issues:

* What happens if I want to change the name of my action
 class?  Now, I have to change all the JSP pages that use
  it, instead of making one change in the config file.  (The
  most common case I've run into for this is when I needed
  to change the Java package containing my action classes).

* What happens if I originally have two different actions (say,
  "/saveCustomer" that saves a new customer, and
  "/updateCustomer" that updates an existing customer), and
  I decide that I now want to use the same action class for both
  purposes since they are so similar?  Again, I have to change
  the links in my JSP pages to reflect this, instead of just
  pointing both action names to the same class name.

The idea of double mapping is to maintain as much isolation as possible.  In this
case, we're trying to let the Java developers change their minds about what classes
are actually used to implement specific actions without impacting the JSP pages
that make up the user interface.  The same philosophy in the other direction is why
you want to use logical "next page" names in your action classes, instead of the
actual JSP page urls -- you don't want a reorganization of the pages in the user
interface to mean you have to modify and recompile the action classes.

In the Struts framework (http://jakarta.apache.org/struts) that implements this
design pattern, I went even further and allowed you to configure other things about
a logical path like "/saveCustomer" than just the name of the action class.  The
example application lets you configure the name of the next logical JSP page here
as well).

>
> Thanks, Bill

Craig

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to