Chapter 7. The Web Request Handling Layer

The request handling layer is the glue that binds the HTTP client to the services provided by your application. It is the interpretation of requests and the transfer of data that is the realm of this layer. Our focus will be on the data that is consumed and submitted by Ext JS 4 clients. This data is in JSON format and we will hence discuss JSON parsing and generation using the Java API for JSON Processing. It is important to note, however, that any type of data can be exposed by an appropriate request handling implementation. It is just as easy to implement an RMI or RESTful interface, if required.

A brief history of Web MVC

It may seem strange to discuss the Model-View-Controller (MVC) paradigm in a historical context, as a majority of web applications still use this technology today. The MVC design pattern first came to prominence in the early 2000's with the open source Struts framework. This framework encouraged the use of MVC architecture to promote a clear demarcation of responsibilities when processing and serving requests. The MVC paradigm for server-side Java development has been around ever since in a variety of formats, culminating in the well-designed and powerful Spring MVC framework.

The rationale for using an MVC approach is quite simple. The web layer implementing interactions between the clients and the application can be divided into the following three different kinds of objects:

  • Model objects that represent the data
  • View objects that have the responsibility of displaying the data
  • Controller objects that respond to actions and provide model data for the view object to process

Each MVC object would behave independently with loose coupling. For example, the view technology was of no concern to the controller. It did not matter if the view was generated by a FreeMarker template, an XSLT transformation, or a combination of Tiles and JSPs. The controller would simply pass on the responsibility to the view object to process the model data.

One important point to note in this historical discussion is that all of the MVC processing was performed on the server. With the rise in the number of JavaScript frameworks, in particular for Ext JS 4, the MVC paradigm has been moved from the server to the client browser. This is a fundamental change to how web applications are being developed and is the very reason that you are reading this book!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.53.93