Craig,
Is your "action class" a servlet or is it a bean that is "servlet aware" by
importing the javax.servlet.http classes and knowing how to forward to the
correct JSP page? I want to try this design with a controller servlet for a
small application, it sounds great. Do you have any type of UML diagram,
such as a sequence diagram, that shows the flow and coordination between the
controller servlet, action class, and business/database beans? TIA, Bill
Hines
-----Original Message-----
From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 05, 2000 11:39 AM
To: [EMAIL PROTECTED]
Subject: Re: More on Model 2 architecture...
Mistroni Marco wrote:
> hi all,
> i just want to post my idea and have some feedback, especially
from
> the gurus of the Model 2 architecture....
> i have been developing JSP using JavaBeans and <jsp:get /set
> Property.....so that all the logic is in the JavaBean...
> and the presentation in JSP pages...
> however, i still have some lines of java code in the JSP..'cause sometime
i
> have to check the parameters submitted by the user
> now that i faced the Model 2 architecture...my question is:
> why don't use Model 2 architecture in the following way?? :
> - we have a Servlet/controller
> - some Action classes..like what was described in previous threads by
Daniel
> Lopez, Kevin Duffey, Craig McClanahan
> - some JavaBeans used directly by the JSP to retrieve the various
> properties..
>
I believe this is what we have been suggesting, which means I don't think I
understand what you are asking.
The action class initiates the appropriate business functions, stores
results as
JavaBeans -- either in the request or the session, depending on how long you
need
them -- and then forwards to whichever JSP page should be used to display
the
results.
>
> this way..i don't need , if for example i have to manage lot of JSP, to
have
> a config file in which i have to put all the JSP URL..
> and neither to forward the request back from the Servlet to the JSP's...
> i would like to have opinion on that from as much people as
> possible.....'cause i would like to know what are the
> possible drawbacks
>
The reason that I use forwarding back to the JSP page is because:
* The beans I use don't know anything about the web -- they
are just JavaBeans. They don't import any of the javax.servlet
classes, and they don't generate HTML.
* The action class's sole purpose in life is to execute whatever
business logic is required. Creating the output that results from
executing this is the sole purpose of a JSP page, which is why
I forward control to the appropriate one.
* Sometimes the "appropriate" JSP page is different (for the same
input) based on what the user entered. For example, assume you
have a form that has fields for a record you want to store in the
database,
but you have some validation logic (for example, a postal code entered
by the user must be valid) that can only be checked on the server. If
the user made a mistake, I want to forward back to the original input
form (with an error message) so that the mistake can be corrected. If
the user did not make a mistake, I want to have my JavaBean store the
result in the database, and go on to the next piece of the application.
* The JSP page that displays the results should not care how those
results were created -- it should only know things like "if I want to
display the name and address of my customer, use the getName()
and getAddress() methods of the CustomerBean with id 'customer'
from the session." This way, you can change the visual appearance
of the output pages without messing with the logic that created the beans.
>
> thanx in advance and best regards
> marco
>
Craig McClanahan
===========================================================================
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