Hi all,

In the interest of our discussion on Model 2, a co-worker (Java guru) has
asked me why there are so many classes involved in the steps as I showed
him. I explained that there is a controller servlet, action class, javabean,
ejb (possibly both session and entity) and jsp page. The javabean is being
used to do nothing other than holding the "data" from the form submitted
(and later, the forwarding JSP page would use this same javabean to display
the resulting dynamic content), and the ejb would also use this same
javabean (as a serialized object) to be passed in as the parameter, so that
when the ejb does its logic, it can populate the javabean and send back the
modified javabean (containing possibly results from database, etc in its
properties).

He made in interesting point. If the action class only implements this
Action interface, thus the perform() method, (note..this is in my current
implementation of it, not the more advanced ones Daniel and Craig are
using), why not eliminate the action class, and put the perform method into
the JavaBean itself? In this way, since its only one method (in my case so
far), there are not two classes being used, but one instead. The JavaBean is
THE action class, so when the perform method is called on the .newInstance()
of itself, it can use "this.xxx" to store its results in.

The flow, in the way I am talking about, would be something like:

1) request comes in to controller servlet
2) controller servlet does the lookup in XML file and creates instance of
javabean class.
3) controller calls javabean perform() method.
4) javabean perform populates itself with parameters from the request.
5) javabean calls EJB to do logic, passing itself as the parameter, so the
ejb can store its results (and use the javabean properties already populated
by the form/request object) into the javabean.
6) EJB passes back the javabean, which then returns a value based on the
result.
controller servlet the gets the forwarding page out of DOM (from xml) based
on the return value and forwards to that page.
7) JSP page uses same JavaBean to display dynamic content.


A few things I am not sure about. Mostly due to not much knowledge of EJB
works. I know that you must pass a serialized object to an EJB, and that is
why a ResultSet can't be passed back. With what I am saying, by using the
JavaBean/Action class as one, you pass "this" to the ejb, and get "this"
back. My question is..can this even be done? Would it be something like

this = ejb.doLogic(this);

I know the above isn't right..but exactly how could I pass the "this" object
to the ejb, and get the SAME object back, most likely modified? Or would I
have to create a new instance of a javabean such as:

MyBean bean = ejb.doLogic(this);


And then put it into the request or session?

Ofcourse, if this is the case, what happens to the reference "this" points
to? Once in the javabean, I can't just delete the "this" reference to get
the gc to handle it can I?

Ok..thats it for now. Looking for some good feedback if this is a good way
to do it or not, and why or why not.

Thank you.

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