Craig,
Thanks. I appreciate your comments. I believe in seperating the presentation
from the business logic.
Kamalesh.
-----Original Message-----
From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
Sent: Sunday, April 09, 2000 7:59 PM
To: Loganathan, Kamalesh
Cc: [EMAIL PROTECTED]
Subject: Re: Model 2 Question..
"Loganathan, Kamalesh" wrote:
> Craig/and All,
>
> I've been following the Model 2 thread. I've the following model
working.
> I've customized the Model 2 to meet our business requirements.
> (constraints??). Could you all please review and comment ? Here is the
> overview.:
> * The HTTP request arrives and is dispatched to the Controller
> (Router) servlet. This is done based on configuration rules provided when
> the application is installed.
> * The controller servlet delegates the request to appropriate
servlet.
> (Why can't we use a 'servlet' instead of 'action' class ? What are the
> disadvantages?? ) The application servlets acts as command beans and
> implements the customization required for the application. The
controller's
> sole responsibility is to delegate the requests.
I don't do this, primarily for this reason: to me, the purpose in life of a
servlet is to respond to an HTTP request and do something with it. But, in
my
Model 2 scenario, I want to require requests to pass through my controller
servlet
because I might be doing some extra checking or processing. If your action
classes
are servlets, you might as well be calling them directly, rather than going
through
the controller -- but now you can't have the common processing of every
single
request that you get with a single entry point.
If you don't care about that, it's probably fine -- but PLEASE don't succumb
to the
temptation to have your "action servlet" generate HTML output directly
(instead of
forwarding to a JSP page). That just gets you back into mixed presentation
logic
and business logic, which is the thing you're trying to avoid with a Model 2
architecture in the first place.
>
> * The application servlet makes calls on one or more service beans
to
> perform the logic of the request. All application servets requiring
> security extends a SecureServlet which implements page and event level
> security.
Sounds reasonable.
>
> * The service and beans implement the business logic and may
leverage
> relational database access, connectors, or the Web application
> infrastructure to perform its computations.
Yep. That's the basic idea. (They can also interact with EJBs if needed).
>
> * Based on the results of the computation the servlet either selects
> and invokes a JSP or does an HTTP redirection to another structured
> interaction. In the former case, the servlet will need to post some of the
> results (Datastore, DataSheet - glorified hashtables.) of the computation
to
> the execution (HtttpRequest & HttpResponse) context for use by the JSP
> before calling it. In the latter case, the servlet will usually need to
> place some of the results of the computation into the session context so
> that it can be picked up by the next interaction.
If you use RequestDispatcher.forward(), you can store the intermediate
results in
request attributes as well, if you don't need them past the end of the
current
request. If you do HTTP redirection, you are pretty much forced to use the
session, and then remember to clean things out when you're done with them.
(The
HTTP redirect also takes longer because of the extra round trip to the
client
browser.)
>
> * The dynamic content on the selected page is filled in from the
> request and session context and the page is sent to the client. This may
> leverage:
> formatting beans, other JSP pages, and static content components.
>
Sounds good.
>
> Thanks,
> Kamalesh.
>
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