Web Application Design With Servlets and JSPs

download Web Application Design With Servlets and JSPs

of 2

Transcript of Web Application Design With Servlets and JSPs

  • 7/31/2019 Web Application Design With Servlets and JSPs

    1/2

    Web application design with servlets and JSPs Application structureThe general structure of a well-architected user interaction in a Web applicationisshowninFigure256.The major parts of such a design are discussed in the sequence of the flow oftheapplication.1

    2

    3HTML pageThe inputpage foreach step iseitherastaticHTMLpageoradynamic HTMLpage created from a previous step. The HTML page contains one or multipleformsthatinvokeaservletforprocessingofthenextinteraction. Input datacan bevalidated through JavaScript in the HTMLpageor passed to the servlet fordetailedvalidation.

  • 7/31/2019 Web Application Design With Servlets and JSPs

    2/2

    ServletTheservletgets control from theApplicationServertoperformbasiccontrolofflow. The servlet validates all the data, and returns to the browser if data isincomplete or invalid. For valid data, processing continues. The servlet sets upand callscommand beansthatperform thebusiness logic. The servletinitializesthe view beans and registers them with the request block so that the JSPs can find the view beans. Depending on the results of the command beans, theservletcallsaJSPfor outputprocessingand formatting.Command beansCommand beans control the processing of the business logic. Business logicmay be imbedded in the command bean, or the command bean delegatesprocessingtoback-endorenterprisesystems,suchasrelationaldatabases,transaction systems (CICS, MQSeries, IMS, and so forth). A command beanmayperformonespecificfunction,or itmaycontainmany methods, each foraspecific task. Command beans may be called Task Wrappers in such a case.Resultsofback-endprocessingarestoredindatabeans.Data beansData beans hold the results of processing that was performed by the command bean or by back-end systems. For example, a data bean could contain an SQLresult or the communication area of a CICS transaction. Data beans may not provide the necessary methods for a JSP to access the data; that is where theviewbeansprovidethefunction.View beansView beans provide the contract between the output producing JSPs and thedata beans that contain the dynamic data to be displayed in the output. Each viewbeancontainsoneormultipledata beansandprovidestailoredmethods sothattheJSPhasaccesstothedatastoredinthedatabeans.JSPsThe JSPs generate the output for the browser. In many cases that output againcontains forms to enable the user to continue an interaction with theapplication. JSPs use tags to declare the view beans. Through the view beans,theJSPgetsaccesstoal l thedynamicdatathatmust bedisplayedintheoutput.Model-View-ControllerThis design follows theModel-View-Controllerdesignpattern:TheJSPs(and HTMLpages)providetheview.Theservletisthecontroller.Thecommand beansrepresentthemodel.The data beans contain the data of the model, and the view beans are helperclasses to provide a data channel between the view and the model. The servlet(controller) interactswiththemodel (thecommand beans)andtheview(theJSPs).Theservletcontrols theapplicationflow.