The Struts framework is an open-source product for building Web applications based on the model-view-controller design pattern.
It uses and extends the Java Servlet API and provides a controller servlet as well as the skeleton classes for actions that developers need to extend and implement the " execute " method
The struts-config.xml file located in the WEB-INF directory of your project, describes everything about the coordination of requests and responses mapping actions to classes and conditional views for responses.
In this tutorial we will use the graphical Struts builder in MyEclipse to create a simple Action, Form and JSP.
Flow begins at the view JSP which will display a list of Books with functions to add and delete from that list.
When either function is called it makes an HTTP POST to the mapping for our Action class in the struts-config.xml.Action mappings end in.do and are directed for processing by the Struts Controller.
The Struts Controller forwards the HTTP Request to our Action class, where the function is determined and a reference made to our Session Bean facade.
The "add" or "delete" CRUD method is called and a Book Entity Bean is created or deleted.
Finally, the user is reshown the same JSP as is specified in the struts-config.xml and the request and response cycle is complete.
|