4
STRUTS Struts is a open source frame work apache software foundation (ASF) Struts frame work is web frame work which will help the web developer. Develop to web based application with low cost and within less time. Struts frame work was implemented based on the following design pattern Front controller design pattern MVC design pattern Struts frame work was implemented based on the following web technology. Struts flow After developing the struts application after deploying it is the server & when you started the server then following things will happened Container initializes the web.xml When container reading the data from web.xml container checks all the servlets configure if container at the load time then container try to load the servlet in to the main memory in our same are they configure one servlet called action servlet with load on startup tag Because of the container loads the action servlet in to the memory,instance will be created and then init method will be called. Inside the init method they implement the code using SAX parser to read the data from struts configuration time(to file which you are passing init parameter) once init method is completed all the data from struts configuration file will be loaded into main memory.if any problem happened while passing the xml documents error will be located the file and may not allow tomcat startup. When you send the request to post problem.jsp to display that in the browser following things will happened :--------- 1 st request will be given to action servlet Action servlet receive the request and then deligate the request to request processor. Upon receiving the request by calling the following things Incoming request uri(from tag action attribute value) will be compare against path attribute value of action tags configure in action mapping .if the mapping action is not found. Then the error message (500)called “cannot retrieve mapping for the action/post99”it will be display to client. If the maching action is found then its name attribute value will be taken With that name RP(request parameter) verify all the form bean configured to check any form bean tag name is mapping with if no names is matching with the given name then error message called “canot retrieve definition for from bean pForm will be display to the client. If it is found then its types attribute value will be taken which is nothing but form bean java class fully qualified name. Form bean java class will be verified if it is not found then error message called exception creating bean of class com.jlc .dev problem from 99 which will you not provided.

Struts

  • Upload
    phani

  • View
    217

  • Download
    1

Embed Size (px)

DESCRIPTION

st

Citation preview

STRUTSStruts is aopen source frame work apache software foundation (ASF)Struts frame work is web frame work which will help the web developer. Develop to web based application with low cost and within less time.Struts frame work was implemented based on the following design pattern Front controller design patternMV design patternStruts frame work was implemented based on the following web technolog!.Struts flowAfter developing the struts application after deplo!ing it is the server " when !ou started the server then following things will happenedontainer initiali#es the web.$ml %hen container reading the data from web.$ml container checks all the servlets configure if container at the load time then container tr! to load the servlet in to the main memor! in our same are the! configure one servlet calledaction servlet with load on startup tag&ecause of the container loads the action servlet in to the memor!'instance will be created and then init method will be called.(nside the init method the! implement the code using SA) parser to read the data from struts configuration time(to file which !ou are passing init parameter) once init method is completed all the data from struts configuration file will be loaded into main memor!.if an! problem happened while passing the $ml documents error will be located the file and ma! not allow tomcat startup.%hen !ou send the re*uest to post problem.+sp to displa! that in the browser following things will happened ,---------.st re*uest will be given to action servletAction servlet receive the re*uest and then deligate the re*uest to re*uest processor./pon receiving the re*uest b! calling the following things (ncoming re*uest uri(from tag action attribute value) will be compare against path attribute value of action tags configure in action mapping .if the mapping action is not found.0hen the error message (122)called 3cannot retrieve mapping for the action4post556it will be displa! to client.(f the maching action is foundthen its name attribute value will be taken%ith that name 78(re*uest parameter) verif! all the form bean configured to check an! form bean tag name is mapping with if no names is matchingwith the given name then error message called 3canot retrieve definition for from bean pForm will be displa! to the client. (f it is found then its t!pes attribute value will be taken which isnothing but form bean +ava class full! *ualified name.Form bean +ava class will be verified if it is not found then error message called e$ception creating bean of class com.+lc .dev problem from 55 which will !ou not provided.(f the class is found then it will be loaded and it will be instanciated and initiali#ed.Form bean ob+ect will be stored in the given scope (value of scope of scope attribute)0he re*uested 9S8:s displa! to the client (8ost problem.+sp) %hen user check the submit button after entering in the fields then following things will happened ,-----------------7e*uest will be submitted to action servletAction servlet delegates the re*uest to re*uest processor .7e*uest processor identif! the corresponding action for the incoming re*uest .78 identif! the form bean name and then its t!pe.78 retries as creates the form bean ob+ect.8opulate the clients submitted into form bean ob+ect.78 takes the t!pes of the action (av;ction belongs name will be..)Action class within form instantiated in if r is coming at the .st time otherwise created instance will be retrives from application scope 78 invokes the e$cuted b! pass the pass b! follow four parameter ,---------------Action mappingAction formAction http re*uestAction http responseode inside the e$ecute method intercect with the model component and get the re*uest after passing the results action forward ob+ect will be returned b! the e$ecuted method to re*uest processor.78 takes the returned action forward ob+ect(which is associated with forward name) and identif! the corresponding forward in struts configuration files78 takes the path(+sp) specified for the identified forward and the same will be forwarded to the client %hen !ou are developing web based application using servlet and 9S8 and using MV front controller design patter !ou can get the following results,------------ode duplication problem8resentation la!er components and controller la!er component will be tightl! coupledMaintenanceproblem Comparission%hen !ou are implementing re*uest without struts the! need to update the controller ever! time with man! if condition. 0his leads to the complicated logic inside the controller servlet and is unmanageable and error thrown !ou need to hard code the +sp name inside the +sp in the case of non struts application where as +sp name is centrali#ed in the in the struts configuration file. 0his reduces lots of maintenances. (n the case of non struts application !ou need to hard code the +sp inside the action class when the !ou create the re*uest dispatcher whereas in the case of struts application +sp name will be centrali#ed in struts configuration file to reduce the maintenance .(n the case ofnon ) application developer has to implement the code for this support .where as in case of struts application building support is there forinternationali#ation (( .= >) %hat is the use of action mapping?%h! ( have to use struts to develop web based application?an ( give duplicate value for the @load-on-startupA?an ( give 2 (#ero) value for the @load-on-startupA?an ( give - (negative) value for the @load-on-startupA?%hat are the difference between 9A7 and %A7?%hat are the use of debug and detail init parameters?%hat will happen when ( am not providing @load-on-startupA for action servlet?an ( configure the filters for the struts application?%hen action servlet will be instantiated?Bow man! instance of action servlet will be created?an ( replace the action servlet with m! own servlet called +lc action servlet?%hen re*uest processor class will be instantiated?Bow man! instances of re*uest processor will be created?an ( replace re*uest processor class with m! own class called +lc re*uest processor?Bow man! instances of action class will be created? Bow man! instances of form bean class will be created?an ( take m! own name for the struts configuration file?%hat is the default value of scope attribute in the action tag?%hat is the default value of validate attribute in the action tag.%hat is the responsibilit! action servlet? %hat are the responsibilit! of the re*uest processor class?(t is minator! to use C.do as /7D pattern in action servlet can ( use C.+lc? %hat are the design pattern used in the struts?%hat is the use of debug and detail init parameters providing in action servlet configuration?an ( take same url pattern for multiple servlet?an ( change the name of web.$ml to +lc.$ml?