there are myriad approaches to architecting logon and user management in the j2ee environment. this article addresses some alternative j2ee architectures as well as the strategy used by each alternative and the code for implementing each solution. ill focus on the end user - not the business purpose of many of todays medium- to large-scale web apps - but my primary focus will be on state-of-the-art solutions.
first, some background information on struts and mvc frameworks: struts is on its way to becoming a de facto standard for developing medium- to large-scale web-based applications on the java platform. struts fits nicely into the j2ee technology stack by filling some gaps not addressed by the servlet/jsp standard or the ejb standard. a framework can isolate the developer from the ever-changing j2ee apis and make it easier to get j2ee applications completed in a shorter time frame. (although, caveat emptor, struts is an ever-changing api.) a framework does this by taking care of the low-level plumbing and difficult programmatic challenges involved with building a j2ee application. basically, a good framework will do the dirty work for you. for more details, see the references section at the end of this article.
lets begin with the end user at the client in figure 1 or 2 and work our way toward the server shown in bold outline at the right side of these figures. figure 1 shows a filters-based design. filters sit between the end client and the requested resource and are able to intercept the request before the resource sees it. figure 2 shows another design where front-end processing is incorporated into the application; in the latter case, changes to one component mean changes to the application proper. struts apps can be built either way.
filter strategies
before launching into filter strategies, heres a brief introduction to filters - a feature introduced in the servlet 2.3 api. the contents of the filter are written in java and are thereby flexible and easy to maintain without touching the application code. as shown in figure 1, filters can be chained and ar... 下一页