Model View Controller

 
 
The Controller [controller.java]
The controller servlet receives all requests (post, get, etc.) .
By default, it looks for a parameter "param0" and gets that value.
Then it uses that value as key to locate for a URI mapping in a file "controllerActionMap.properties" like below. The controller forwards
 the request to that target URI which is the Model component.

# Controller mapping
#
# used by controller

#
#  Value                        URI

targetNotFoundErrorJSP = /jsp/error/controllerTargetNotFound.jsp
multiPartJSP           = /jsp/model/upload.jsp
debug                  = /jsp/debug/debug.jsp
adminLogin             = /jsp/model/loginProcess.jsp
fileChangeDir          = /jsp/model/fileChangeDirProcess.jsp
fileCreateDir          = /jsp/model/fileCreateDirProcess.jsp
fileDelete             = /jsp/model/fileDeleteProcess.jsp
fileUpload             = /jsp/model/fileUploadProcess.jsp

 
The Model [Servlet + JavaBean] or [JSP + JavaBean]

The model component receives the request forwarded to it by the controller servlet. It read the parameters and applies business logic to it using JavaBeans. After processing, usually it forwards the request + some other new parameters that resulted from its process to either a JSP page for viewing or to a SQL servlet that gets a database connection from a recycled pool of connections.

The SQL Servlet
If processing requires database operations e.g. insert, update, delete, etc., then, the model component forwards the request and other new parameters resulting from thr processing to the SQL servlet. This servlet gets connection from the database connection pool and performs a SQL operation. When done, it forwards the reulst of that SQL operation to the view component.

The Database Connection Pool
The database connection pool maintains a number of open connections that is recycled after use and released back to the pool. It can be implemented using several libraries available, e.g. Jakarta DBCP, JavaExchange.com DBConnection Broker.

 
The View [JSP + JavaBeans + Java Tag Libraries]
The view component is just a display of processing results from the model component or SQL servlet processing.
 
Note: Code templates are provided when you create any of the web application files. You may add your own code templates.

posted on 2004-10-26 13:33  Java & .Net  阅读(310)  评论(0)    收藏  举报

导航