<Kevin>
Yes..this is correct. However, as Craig often says..your mileage may vary in
how you implement it. Because ALL actions will forward to a JSP page, I
decided to put the forwarding call in the controller servlet itself. The
reason for me is that I can centrally locate the ability to catch any
uncaught exceptions, put them in the REQUEST object, then forward to the
right JSP page, all in one location. This means each action class does NOT
forward, and thus the reuse of the forward call (probably minor). However, I
DO allow the action class to return a String representing the jsp page to
forward to. Thus, the action class still can dictate what JSP page it
forwards to simply by returning the path and page name. This, in my opinion,
is a bit better in design (as far as I know..correct me if I am wrong),
because instead of placing any exceptions that may occur in each action, I
can catch them all in the controller servlet and do it one time (code wise)
there, and forward one time (code wise) there. I am repeating myself aren't
I? ;)
<Kevin>

I approached forwarding a little differently. My configuration XML file
contains the page to forward. ActionServlet calls Command (aka Action class)
which is responsible for business logic and is not controlling the flow.
Upon return, ActionServlet forwards to the next page defined in XML
file(through the use of aggregate Helper class).

e.g.: configuration DTD fragment:
<!ELEMENT url-mapping (request-url, class-name, target-url?)>
<!ELEMENT request-url (#PCDATA)>
<!ELEMENT class-name (#PCDATA)>
<!ELEMENT target-url (#PCDATA)>

e.g. of XML configuration file fragment:
 <!-- Here goes mapping area, add pages and action mappings when needed -->
<url-mapping>
  <request-url>getClaimDetails</request-url>
  <class-name>ClaimDetails</class-name>
  <target-url>/jsp/ClaimDetails/ClaimDetailsRequest.jsp</target-url>
</url-mapping>

My approach does not deal yet with errors and this needs to be rectified.
This fragment should include error situations and pages to forward to.
Command/Action class should throw specific error or exception, ActionServlet
should check this exception against the XML file and find the related error
page. If no match was found - browser needs to be forwarded to central error
page (something like central login page).

Vadim Shun
NEW Corp
Dulles, VA

===========================================================================
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