Struts2 Black Book - Ebook download as PDF File .pdf), Text File .txt) or read book online. I use struts, a native of the demo from the struts2 which you can see it before the ruthenpress.info configuration and a bit different, there is another kind of. Attached: Hello-Flex.4 PDF and the book source code Description Book Description: Flex should be as easy to learn as it is to use. And with Hello! Flex 4, it is!.

Author:EVANGELINE BRELJE
Language:English, Spanish, Portuguese
Country:Sierra Leone
Genre:Fiction & Literature
Pages:165
Published (Last):30.11.2015
ISBN:427-7-32638-222-4
Distribution:Free* [*Register to download]
Uploaded by: HOYT

74295 downloads 112685 Views 35.44MB PDF Size Report


Struts2 Black Book Pdf

I was interested in teaming up with Don Brown to write a Struts 2 book for their In Action In some ways, the model is a black box that contains the guts of the. DownloadFree of struts2 black book pdf. Get file Makes me a little ashamed of my own text mode posts. write Lumia s reply to my tweet. Name: Struts2 Black Book 2nd Edition Pdf File size: 14 MB Date added: June 25, Price: Free Operating system: Windows XP/Vista/7/8.

Struts 1. Still there are lots of projects written in Struts which needs active maintenance and that's why Struts developers are still in demand. It has close competition with Spring MVC but given the demand for Struts developer, it's still a good technology to learn if you are looking for the job in Java web development position. What is the best way to learn Struts? Well, you can start with books and who doesn't like free eBooks and I am going to share some of the good free Ebooks to learn Struts, useful for both Java and J2EE developers. First two books are really good for any Java EE developer looking to learn Struts 1 or Struts 2 by himself. Remember, Struts 2 is completely different from Struts 1, you should check these differences for quick comparison. This book teaches you how to build dynamic websites in Java using Java Server Faces, using a hands-on, practical approach. You will learn how Struts framework works, learn how to build your first struts application, all about actions, form validations, error handling, struts tag libraries, tiles, internationalization and the right way to use the struts framework. Very useful book for both Struts beginners and experienced alike.

Servlet contexts are represented as simple Maps that allow Actions to be tested in isolation. Act ionSupport class to implement the commonly used interfaces. Reuse of views to a range of types that may have same property name but different property types are allowed by using ValueStack strategy Servlet Dependency When an Action is invoked the HttpServletRequest and HttpServletResponse are passed to the execute method.

Thus Struts 1 Actions are singleton and must be thread-safe. Action interface is not required. Also the dependency injection support also makes the testing simpler Struts 1 supports separate Request Processors life-cycles for each module. The singleton strategy places restrictions on what can be done by using Struts 1 Actions and thus requires extra care to develop There are no thread-safety issues because Action objects are instantiated for each request in Struts 2 Testability The execute method exposes the Servlet API.

Rich object types. The chapter concludes with the comparison of Struts 1 and Struts 2. This chapter embarks with Struts 2 Framework and Web application Frameworks.

This Action property is accessed from the web page via the taglibs. The EL is more powerful and very flexible. All ActionForms must extend a base class. Input properties may be rich object types with their own properties. Chapter 1 Table 1. This explains where Struts 2 is different from Struts 1 and what makes it preferred over Struts 1. Since other JavaBeans cannot be used as ActionForms. Struts 1 uses an object of ActionForm. The next chapter covers the essentials for the development of Struts 2 based Web applications— downloading required APIs.

The XWork Validation framework supports the chaining validations into the sub-properties by using the validations defined for the properties class type and the validation context Type Conversion The type-conversion is performed by Commons-Beanutils. DynaBeans can be used for creating conventional ActionForm classes. See page: Any framework comes with its own set of APIs which can help you to create different components to be used within the framework.

But as the work flow is quite simple in Struts 2 through the different components development and their execution in the application. The standard directory structure of Struts 2 Framework should also be explained earlier to any component development. Results and other configuration techniques to be used in Struts 2 quite new and difficult when used for the first time.

Setting Struts 2 Environment Before getting started with your Struts development. The way different components are designed and configured in Struts 2 Framework makes Web application development faster. But the flexibilities introduced and support for the concepts of Interceptor. You might find the interfaces. We need to understand these APIs which has been developed for the implementation of all framework features. This Struts 2 application creation here will support our further discussion on the new techniques and traditions introduced in the framework.

Inversion of Control. Platform Requirements To construct a Web application using Struts 2. Different interfaces. Directory structure of First Struts 2 Web application. Download the binary distribution of Struts 2. Table 2. This directory structure is the container that holds the components of a Web application. Other important subdirectories which can be found here are as follows: Once you have the Struts 2.

You can start with the following steps to start with a standard Web application directory structure: Directory Structure All the Web applications are packaged into a standard directory structure. You can download the latest version of Struts 2 from the Apache website http: Figure 2. You will get a directory struts At the time of writing this book. Follow these steps for getting prepared before you start coding for Struts 2-based Web application: The following code snippet shows the basic structure of struts.

The following code snippet shows the basic structure of web. For developing this application. The JARS added for this application are as follows: Struts 2 action class files and other utility classes are located. Creating Application in Struts 2 Table 2. Different components created here must be placed in the application folder within the subfolder specified for it.

Create all the Views. It is discussed in the coming chapters. You already know by now that the Struts 2 application is based on MVC design pattern. A Struts 2 application consists of JSPs. This application can be described in the following steps: Developing First Application in Struts 2 Now that you have a fundamental knowledge of Struts 2 Web application directory structure. You can also create a separate class for your Model. The process of creating a Web application using Struts 2 begins with the identification of the Model.

We need to create various JSP pages. Deploy and run the application. Struts 2 configuration files.

Top 3 Free Struts Books for Java EE developers - Learn Online, PDF download

Modify your web. Establish the relationship between the Views and the Controllers action mapping in your configuration file.

Creating Application in Struts 2 Figure 2. Directory structure of a Struts2Application with different components. The html tags. According to the input text. Listing 2. The index. The development of various JSP files. To create your view components. Creating index. The value used in this example is validField. The action attribute represents the URL to which the form will be submitted.

This attribute is also used to find the appropriate action mapping in the Struts configuration file. Its attributes are method. To develop this Web application. Submitted Successfully. Creating client. Creating error. Creating Application in Struts 2 user is allowed to input some text. This view page displays only when there is some error on index. When the user submits name. Upon submission. When the user leaves any field.

In our case. ActionSupport class. The data sent from index. For example: String in place of Integer. The action classes are used to call Business logic and data access code.

This configuration file uses different elements. Results are used to prepare views. Creating Application in Struts 2 All the input fields to be submitted from index. It is used as a glue to initialize your own MVC resources.

Configuring Actions in struts. These resources are Interceptors. Interceptors are used to pre-process and post-process a request. There are several elements that can be used to configure in struts. Next compile this file to get ClientAction. The attribute of package element may be name. Package Configuration Package is used to group actions.

Make sure that the ClientAction. These elements are packages. The class attribute of action element is the class name of your action class to be executed here with full package description. After matching the result value. For this we have configured a result with the name input. To do this. The extends attribute is an optional attribute. The abstract attribute is optional.

This String value is used to select a particular result element. Chapter 2 abstract. When the execute method of action class completes. The name attribute of package element acts as the key. Configuring Struts 2 in web. The action mapping requires name attribute. The element of action attribute is name and class. Result Configuration The result element is used to display your desired view.

The action maps an identifier to handle an action class. The namespace attributes helps in separating different packages into different namespace. Update your copy of web. In our Struts2Application example. It allows one package to inherit the configuration of one or more previous packages. This makes sure that all kinds or request patterns are served by org. The name attribute is the name of the action. It is used to execute Business logic and data access code of your action class.

Action Configuration The action configurations are the basic unit-of-work in the Struts Framework. Deploying Struts 2 Applicaiton Any Web application needs to be deployed on some Web server or any application server which are compatible with the technologies used in the development of application. In that way the application is automatically deployed. You can see the code being executed in Figure 2. You can also place the created WAR file into webapp folder of your Tomcat installation.

You can give a name of your choice also. In this case. You can create a WAR file for the application using the following command: Creating Application in Struts 2 http: There are three different ways to deploy your Web application on Tomcat: Make sure that all JSPs. Chapter 2 Figure 2. Now we can deploy this WAR file using the following steps: Browse to the location of WAR file created and select it to deploy Figure 2.

Creating WAR file of application. Start your Web Server. Deploying Struts2Applicaiton. When this page loads. If everything is correct. Creating Application in Struts 2 You may have your Web server listening to another port other than The application is now ready to be run after its successful deployment on the Web server. The container finds the following entry. So change the port number here accordingly.

Running Struts 2 Application A deployed Struts 2 application can be accessed similar to other Web applications. You can access your first Struts 2 Web application that has been deployed on Tomcat Server by using the following URL in the address bar of your Web browser: ClientAction action class. Here we can only tell you that we using defaultStack as Interceptor stack. The String value which is returned by execute method is matched with the result name attribute of the results configured for the associated action in the struts.

Before the execute method of ClientAction class is executed. The FilterDispatcher looks for an action mapping entry in the struts. In Chapter 4. This automatic setting of properties is assured by the use of some Interceptors. The error. The String value. Output of client.

The discussion is supported by a running application. Chapter 2 With this we complete our first Struts 2 based Web application. In this example. The different components of Struts 2. The next chapter will deal with a detail discussion on the action classes created in Struts 2 based applications and concentrate on the different concepts regarding creation. This chapter focussed on the basic requirement. But the way action classes are created.

Struts 2 has introduced a simpler implementation for its action class which can be created by implementing some interface. The return from the action class. An action class is created to handle a given action.

In addition to these basic conceptual similarities with Struts 1. We can have a number of action classes embedding different business logics for a particular user action. In Depth Struts 2 is a Front Controller based framework. In this chapter. The way an action class is executed in the framework environment by the controller artifacts. The implementation of Inversion of Control IoC through enabler interfaces allows the handling of only optional and custom services. Struts 2 action classes are similar to the action classes created in Struts 1 Framework in many aspects.

In addition. Like Struts 1. In few words. These classes. The concept of handling actions. GetProductAction etc. These action classes help in applying separation of concerns as we can see a required functionality as a sequence of actions and each action class being executed for a specific functionality. The flow of execution of an action class involves a sequential invocation of different methods. The discussion here includes different interfaces and classes from Struts 2 APIs which are used to develop actions in Struts 2.

Both Struts 1 and Struts 2 actions has execute method as the default entry point where the execution of an action class starts. Handling Struts 2 Actions Any required function can be performed with the execution of a single action class or set of action classes.

This sequence of method invocations are handled by different Interceptors. Struts 2 actions are not singletons. This is again a new option which can be implemented.

Action class only. So how can we access different objects to work with. The only convention to be followed is the availability of execute method in the action classes. Action interface or by extending com.

Struts 2 action need not be thread safe like Struts 1 actions. The solution of this problem is Dependency Injection pattern. In Struts 1. For every request. Chapter 3: Creating Actions in Struts 2 implementation. The action classes are now simple and do not depend on other APIs. These action classes are known as POJO actions and does not depend on any container.

The result configured for this action having the name matching this returned string is executed next. ActionForm form. We can create different number of action classes for different use cases. HttpServletRequest request.

Struts2 Black Book | Java Server Pages | Java (Programming Language)

The return type of execute method of a Struts 2 action class is a String. You can see the difference between the signature of execute method of action classes in Struts 1 and Struts 2 as shown here: These exposed methods should be invoked in the predefined order. Struts 2 provides flexibility in creating a new action class by implementing com. This means.

For adding further functionalities and different methods to our action class. This is the com. Action interface is useful for simple action classes only. ActionSupport class implements interfaces. Though the use of this interface is not required. Action interface which can be used as helper interface exposing the execute method to the action class implementing it.

Table 3. Struts 2 Framework provides an interface which can be used to create action classes. ActionSupport Class Creation of action classes by implementing com. A sample action class created by using Action interface is shown here: In Depth Action Interface Though.

Struts 2 Framework provides a class. String errorMessage It adds an error message for a given field Collection getActionErrors It gets the Collection of Action-level error messages for this action Collection getActionMessages It gets the Collection of Action-level messages for this action Map getFieldErrors It gets the field specific errors associated with this action boolean hasActionErrors It checks whether there are any Action-level error messages.

Validateable interface provides a validate method that allows your action to be validated. Validateable Interface The com. When LocaleProvider interface is implemented in a class.

You must override this validate method in your action class to implement your logic to validate the data. ActionSupport class provides basic implementation for common actions. It is used in an action to override the default locale. ValidationAware Interface The com. A Locale is an object. ValidationAware interface provides methods for saving and retrieving action class level and field-level error messages.

LocaleProvider interface provides a getLocale method to provide the Locale to be used for getting localized messages. Creating Actions in Struts 2 Validateable. LocaleProvider Interface The com. See Table 3.

In addition to Action interface. String defaultValue It gets a message based on a key. TextProvider interface provides methods for getting localized message texts. Methods of ValidationAware interface Methods Description boolean hasActionMessages It checks whether there are any Action-level messages boolean hasErrors It checks whether there are any errors action level or field level set or not boolean hasFieldErrors It checks whether there are any field errors associated with this action void setActionErrors Collection errorMessages It sets the Collection of Action-level String error messages void setActionMessages Collection messages It sets the Collection of Action-level String messages not errors void setFieldErrors Map errorMap It sets the field error map of fieldname String to Collection of String error messages TextProvider Interface The com.

TextProvider is used to access text messages in the resource bundle. List args It gets a message based on a key using the supplied args.

String defaultValue. String[] args It gets a message based on a key using the supplied args. In Depth Table 3. Creating Actions in Struts 2 Table 3. ActionSupport class provides default definitions of methods of all interfaces implemented by it. String[] args. Listing 3. ValueStack stack as defined in MessageFormat. ValueStack stack It gets a message based on a key using the supplied args.

List args. A sample action class package com. String obj It gets a message based on a key using the supplied obj.

The DefaultWorkflowInterceptor Interceptor makes sure that the validate method is executed before execute method. ActionMapping class that describes an action invocation for the Web application. If you give your own Interceptor configuration make sure that the workflow Interceptor is included to enable this flow of execution.

If our package extends struts-default package defined in strutsdefault. For a given HttpServletRequest. It provides a mapping between HTTP requests and action invocation requests and vice-versa. ActionMapper interface may return null if no action invocation request matches. The order of execution in the workflow is as follows: Action Mapping An action mapping is a configuration file entry that is associated with an action name and action class.

The action mapping specifies a set of result types. Fields of ActionMapping class Field Name Description private String method It is method name private String name It is name of the action private String namespace It is namespace of the action private Map params It is optional set of parameters private Result result It is result of the action Table 3.

Tables 3. Creating Actions in Struts 2 ActionMapping is a simple class that holds the action mapping information used to invoke a Struts action. The Struts 2 Framework provides this facility by using action mapping. The following code snippet shows a default action configured in your strut. Action Methods The main method in any action class is its String execute method. There should be only one default action per namespace.

Sample action mapping in struts. In Depth In a Web application. But Struts 2 action classes provide flexibility of defining some other String methodName like methods and invoking them directly using action String methodName. An action class with String methodName methods package com. We can create a single action class UpdateEmployeeAction and two execute methods of the previous two action classes can be converted into two different methods of this new class.

This eliminates the need for creating different action classes for different actions. This is shown in Listing 3. Configuring different action methods in struts.

These methods can be String addEmployee and String editEmployee. We can group similar type of actions into a single action class. The execute method of both these classes will operate on a similar set of data and require similar set of validation rules to be followed.

Creating Actions in Struts 2 configuration. The following code sample shows the use of ActionContext class: ActionContext Class An action context can be defined here as a container. We can obtain the reference of this class using its own static getContext method as shown here: This context is represented by ActionContext class and can provide objects. The execute method of Struts 2 action classes does not take any argument and.

ActionContext helps in obtaining these objects in our action class. The objects stored in the ActionContext are unique per thread as this class is thread locale. The ActionContext. In addition to extending fields and methods from ActionContext.

Struts2 Black Book

Creating Actions in Struts 2 Another class. ServletActionContext class is a subclass of ActionContext. ServletActionContext class. StrutsStatics interface. The StrutsStatics interface contains constants used by Struts. The creation of POJO objects is simple and hence better to design. A simple example of POJO as action is shown here: ActionContext and the StrutsStatics interface implemented by it.

ServletActionContext class inherits all fields and methods from its parent class. Struts 2 provides the facility of taking POJO as actions. It also shows how to organize and encapsulate the domain logic.

These are JavaBeans like classes with validate and reset methods. This eliminates the need of any ActionForm. It means the actions in Struts 2 can also behave as ActionsForms of Struts 2. The developers had to create these additional classes to be associated with each action.

An action class with input fields package com. These ActionForms are automatically populated with corresponding data submitted from JSP pages before executing action classes.

This is discussed later in this section. It is faster. The action class itself can describe the list of properties with getter and setter methods for them. Testing of Struts 2 action classes can be done outside the container. These properties can be accessed in a web page using Struts 2 tag libraries.

This Interceptor finds setter method for all incoming request parameters and invokes them. This Interceptor is part of basicStack and defaultStack Interceptor stack. The only method which is exposed by ModelDriven interface is its Object getModel method. This approach needs some additional implementations. The action class also provides methods to set these input properties.

Now there is a question for you. The model class created here can be any JavaBean like class. The action class must implement the com. What is required for setting all input parameters before the execute method is invoked?

This is an Interceptor named param ParametersInterceptor. These fields can automatically be populated with the data sent as request parameters with the same name. These input fields should be set prior to the execution of the execute method. A model class package com. ModelDriven interface. Object methods. The Interceptors are discussed in detail in Chapter 4. Using ModelDriven Actions Sometimes we may want to implement ActionForm like approach in which the data is held by a separate class.

This method provides the model to be pushed into the Value Stack. Creating Actions in Struts 2 String password. The only method of this interface is implemented in this action to return the object of the model.

The returned model is pushed into the Value Stack of the action if not found null. A model driven action package com. The default factory used in struts 2 is ObjectFactory. IoC provides a way to inject logic into client code rather than writing it there.

We can use the defaultStack. You need to only describe how they should be created. IoC container provides the factory. Inversion of Control IoC is based on how services are defined and how they should locate with the other services on which they depend. The interface to be implemented here is Preparable. This container is responsible for various tasks. The model object to be pushed into stack cannot be null. They follow the principles given here: Dependency injection helps in removing the task of creating and linking objects from the objects themselves.

Chapter 4 discusses more about Interceptors. There are two ways to implement IoC in Struts: So the flow of execution of various methods can be controlled by the position of Interceptors in the Interceptor stack. This will allow the resource to be passed to the said action Object after it is instantiated.

To make sure that the model is available in the Value Stack when input parameters are being set. That is why. The defaultStack is the good one to be used. This task is accomplished using a factory. This enhances the capability of your class and helps in decoupling your class from other APIs.

ApplicationAware interface is used to expose a method to an action class which sets an Application Map object in this action class. Struts 2 uses a technique known as Dependency Injection and Inversion of Control. An action implementing ApplicationAware package com. These interfaces have methods to set specific resources into the implementing class and to make the resource available.

It is something like implementing the required interface. ApplicationAware Interface The org. Common aware interfaces that Struts 2 supports are discussed here. These interfaces are called aware interfaces because the interface names always end with Aware.

Struts 2 implements Interface Injection which is one of the forms of Dependency Injection pattern. In this technique. The Struts 2 tags support the display of different application scope objects using a corresponding key. The ApplicationAware interface has one method.

This Map object contains different objects which are accessible from whole application. This consequently makes action class difficult for unit testing. We can add. The action implementing SessionAware interface can access session attributes in the form of Session Map.

An action implementing SessionAware package com. The SessionAware interface has the method setSession to set the Map of session attributes in the implementing action class. SessionAware interface is used to handle client session within your Action. The interface is relevant only when the action is being used in Servlet environment.

An action implementing ParameterAware package com. Another common use for this interface is to propagate parameters to internally instantiate data objects. ServletRequestAware interface. All the parameter values for a given name will return String data. The ParameterAware interface has one method setParameter Map map. But this can be injected into the action by implementing org.

This allows an action to use the ParameterAware interface is used when an action wants to handle input parameters. These input parameters can also be displayed on JSP using the following syntax which shows the display of two input parameters. This interface is used to inject the HttpServletResponse object into your action. An action implementing ServletRequestAware package com. The only difference is the object injected into action. An action implementing ServletResponseAware package com.

The directory structure of the application is similar to other standard directory structure used for earlier Struts 2 application created in Chapter 2.

This page simply gives you some hyperlinks to run different JSP pages and actions. The directory structure of this Web application. Create a directory structure similar to Figure 3. Figure 3. We can edit and delete user information also. You can copy web. Directory structure of Struts2Action application.

Immediate Solutions Developing a Hello Action Example The application created here basically adds some users in the application context and the list of available users is maintained throughout the running application. The action can use string constants from Action interface. ERROR etc. Action interface.

The HelloAction class implements the execute method. To make these hyperlinks work. The first action class to be created here is HelloAction.

This action class is created implementing the com. Configuring HelloAction All action classes need to be configured in Struts configuration file struts. The action class must have getter methods for all properties to access their values. All the properties defined in an action are pushed into its Value Stack. This can be provided by adding action mapping for the corresponding action class. The value of these properties can be accessed in the next JSP page to be shown as a consequence of string returned from this action class.

A success returned from the HelloAction action will consequently show you hello. This session attribute handling is discussed later in the application. If there is no user attribute in session scope. The object ActionMapping class holds action mapping information used to invoke a Struts action. The org. If not set. The request path having hello. This returns an object org. We can configure the list of Interceptors and results for a particular action.

The first page which appears is the index. Start your server and use the URL http: This will cause you to see the hello. In Listing 3. The output of hello. The hello. This requires that all input properties have a corresponding setter and getter methods following the naming conventions similar to simple JavaBeans.

Map application. The action class field will automatically be populated with the data sent as the request parameter. This becomes possible only when the ParameterInterceptor is configured as one of the Interceptors for the action. Creating Actions in Struts 2 Using Action as ActionForm Struts 2 removes the requirement of creating a separate ActionForm class to be populated with the input data automatically.

The action class created here is UserAction. We can use the action fields as input properties. This class is a simple JavaBean which is used to group single user information. In UserAction action class.

The getUser method searches for the user with the given username and returns an object of User class. The extending of ActionSupport class enables you to use methods. The implementation of ApplicationAware interface brings an Application Map object into role. The objects stored in Application Map is available in the whole application. The ActionSupport class itself implements different interfaces. ActionSupport class and implements org. ApplicationAware interface.

Now add the following action mapping. The execute method makes sure that no two User objects with the same username are added into the application scoped ArrayList. Immediate Solutions Figure 3. The successful addition of new user brings user. If the username entered is unique.

You can see two hyperlinks rendered in front of each user record. These hyperlinks are not functional yet. The user. The output of user. ServletRequestAware and ApplicationAware interfaces. It needs creation of some other action class and JPS pages to make them work. The only interface which needs discussion here is the ServletRequestAware interface. This execute method of this action just obtains an User object having username matching with the username passed as the request parameter to this action.

User user. The HttpServletRequest object is used to get this username parameter and to save the obtained User object into the request scope so that it is available on the coming JSP page. Creating Actions in Struts 2 Configure this action class by adding new action mapping into your struts. The new action mapping is shown here: This User object is set into request scope by the GetUserAction.

But the fields this time are populated with the values of different field of the User object. This method contains the logic to edit the users. The form is similar to what is prepared for adding a new user. Struts 2 allows configuration of any method having signature String methodName to be configured and invoked.

Add a new method into your existing UserAction class. The logic is to replace the existing User object in the ArrayList with the new User object created with new data. The edit method updates the ArrayList and return from this method consequently shows you user. Recompile the action after adding the new method.

The logic embedded in this method is just to remove the matching User object from the ArrayList. This is done by providing a method parameter in the action mapping as shown here: The new action mapping to be added in struts. The validate method of UserAciton would have certainly been executed if we would have used defaultStack as Interceptor stack here all actions configured here uses the default Interceptor stack defaultStack.

This Interceptor is responsible for invoking the validate method before the real business logic method is invoked. The implementation of SessionAware interface enables this action to handle a Session Map which stores objects in session scope.

The reason behind this concept is that the defaultStack Interceptor stack includes DefaultWorkflowInterceptor Interceptor. The success result will be rendered only when such user exists. This sets the username as the session attribute after finding the valid login attempt. Creating Actions in Struts 2 users.

We are creating a class to authenticate the user for its username and password. Map session. String password. The page looks like Figure 3. This consequently shows you login. This JSP page is a login page providing two input fields for username and password. The successful login brings you hello. Add the following action mapping in the struts. The login.

Now the only option left here to be made functional is the Logout option. But it has access to HttpSession object using ActionContext object. Creating Actions in Struts 2 Similarly. The welcome message on that page also changes. This class simply removes the session attribute which stores the username of the currently logged in user.

Struts 2 is not just a revision of Struts 1, it is more than that. Though the working environment, various component designing, configuration, and few other things seem familiar to the Struts 1 developer, the Struts 2 has some architectural differences when compared with Struts 1. In general, Struts 2 Framework implements MVC 2 architecture with centralizing the control using a Front Controller strategy similar to Struts 1, but the basic code of components and their configuration is quite different here.

In addition to introducing Struts 2 as a new Web application Framework, well get into a detailed discussion of this framework which contains every thing that can make it a preferred choice over other frameworks, like Struts 1.

Though Struts 2 is not here to replace Struts 1, we now have one more option to choose from while deciding which framework to use for a new Web application development and Struts 2 has all the potential to replace other Web application Frameworks in the industry.

The key features of Struts 2 starting from Interceptors, Results, integration with other popular frameworks and languages through plugins, XWork Validation Framework support, integration with OGNL and implementation of Inversion of Control IoC make this framework stand apart from the other frameworks. We have discussed all these features through the chapters of this book. Struts 2 is a Web application Framework and will be used for the development of a Web application.

So, before we start describing Struts 2 Framework and its features, we must have a brief discussion over the topics, like Web application and the technology context which can help you understand architectural decisions taken for the frameworks, like Struts 2. So lets begin our discussion with the term Web application first. Overview of Web Applications A Web application is an application that is invoked by a Web browser and executed on the Web server.

Whereas, a Web browser is an application that displays the contents of a Web application, a Web server can be defined as a central computer that is accessible to all the clients and delivers requested resources to them. The interaction between a Web browser and a Web application is shown through a flow diagram in Figure 1. Figure 1. This request is transferred to a Web component, which can communicate with other components, like a database.

There are two types of Web applications. These are as follows: Presentation-oriented Web applicationsThis type of application contains static and dynamic web pages and provides user interaction.

It serves only a collection of web pages that display some information and provide no service to the client. In other words, presentation-oriented applications have only presentation logic and do not implement any Business logic. For example, an online tutorial displays what is written already and interacts with the user to get the desired page displayed. Service-oriented Web applicationsService-oriented Web applications are generally implemented as an end point of a Web service and provide services to the presentation-oriented applications.

Service-oriented applications implement the presentation as well as the Business logic. For example, an online share-trading portal not only displays the status of the share market but also provides services such as downloading and selling shares. In the earlier types of client-server model of computing, there was no standard interfacing mechanism between the client and the server.

Any upgrade to the server would require an upgrade to the client, accordingly. Web applications have overcome this drawback of client-server computing. Web applications generate web documents which are supported by almost all the Web browsers.

This sort of arrangement allows upgrading of Web application without disturbing thousands of clients.

Similar files:


Copyright © 2019 ruthenpress.info.
DMCA |Contact Us