Hi,

Thanks..I do something similar. However, because I want to have the ability
to redirect to more than one possible page from each action, what I am doing
now is having each action return a "result" string. My xml config file will
look like:

<action>
  <name>Login</name>
  <class>package.Login</class>
  <result>
    <value>Successful</value>
    <page>/inside/home.jsp</page>
  </result>
  <result>
    <value>Bad Login</value>
    <page>/outside/login_error.jsp</page>
  </result>
  <error>/error.jsp</error>
</action>


Thus, each "action" DOM read in, can set the name in the lookup table used
to store each dynamically loaded instance (one instance per action class).
The controller servlet first tries to get the instance. If it doesn't exist,
it loads the class and stores it in the "classes" table. Then it gets that
instance.  Upon returning from the action, the result string is compared to
the particular actions "result" tree of result strings and forwarding JSP
pages. If it is found, the page specified by the found result is forwarded
to. If its not, the <error></error> page is forwarded to. If that is
omitted, then /error.jsp is the "default" error page as a last resort.

What do you think? Any ideas on making it better? I thought about having the
action class return an int value for a result to make it faster for a lookup
in maybe an array, but I don't know if thats much faster, and its uglier to
figure out if someone new is looking at it.

Thanks.

>
> Kevin,
> I seem to recall you stating once that you kept the rd.forward out of the
> action classes and in the controller.
> I do the same and in this case adding page tracking is trivial
> since you can
> just add the tracking to the controller and not all the action classes.
> I use a simple session attribute Page.Current as follows:
>
>         // call the action class with recommended page destination
>         // return value is the actual page to go to - it may the
> "next" page
>         // or the original page if any (validation) error occurred and we
>         // want to go back to the page we just came from
>         /// as stated by session attribute Page.Current
>         String nextPage = aow.mObject.perform( this, req, res,
> aow.mTargetPage );
>         // Processing is complete.
>         // Now reroute the flow back to the presentation and the user
>         // update the page tracker
>         req.getSession().setAttribute("Page.Current", nextPage );
>         req.getRequestDispatcher( nextPage ).forward( req, res );
>
>
> Regards
> @
>
> ==================================================================
> =========
> 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
>

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