O'Reilly logo

Ajax Bible by Steven Holzner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 16

Filters, MVC, and Ajax

IN THIS CHAPTER

  • Working with filters
  • Creating an Ajax password filter
  • Creating an Ajax logging filter
  • Creating an Ajax time-of-day filter
  • Creating an Ajax-enabled Model-View-Controller application

This chapter covers some advanced Ajax techniques: using filters and model-view-controller (MVC) architecture.

You can use filters with Ajax to restrict access to resources on the server. Filters can get control of the user's request before that request is passed on to the Web resource the user is trying to get to; so you can use filters for password checking, user logging, even restricting access to Web resources based on the time of day.

The MVC architecture is designed to be used as your Web applications become larger and larger. This architecture provides a way of dividing up your application into distinct parts, following the divide-and-conquer strategy. By separating your Web application into well-defined parts, you can make it easier to maintain and debug.

Restricting Access with Filters

Filters give you control both before and after a user accesses a Web resource on Java-enabled servers. Usually, you get a direct connection between the browser and a Web resource such as an HTML page, Java servlet, or JSP page:

 --------------          --------------
|              |        |   Web        |
|              |------->|   resource   |
|    browser   |        |   (HTML page,|
|              |<-------|   servlet,   |
|              |        |   JSP, etc.) |
 --------------          --------------

However, filters you install get control before and after the Web ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required