Best Practices

There are many options and various situations that Web components can be used for. In general, the Web tier is used mainly for processing user input, server-side validation, and building dynamic content. It's not a good place to put application business logic, access the database, or perform transactions. All Web components are not transactional. Use EJBs to model your application business logic.

Don't put too much logic in JSPs. Use taglibs to capture presentation logic, and JavaBeans as data transfer objects between the Web tier and the EJB tier. Use servlets as controllers as well as delegates on behalf of the client to the EJB tier.

When tracking user sessions, try to activate URL rewriting to avoid disabled cookies by users. Use JSP error pages; they're an elegant mechanism provided by the JSP architecture.

Application servers provide persistence mechanisms for session data storage. You also can choose to maintain the session information in a database. Persistent sessions are slow compared to replication of session information across cluster nodes. Here, only serialiazable objects can be replicated or persisted. Large data stored in collections, arrays, or tables should not be replicated because it's hard to detect changes to them.

One advantage of using servlets is that they can be used by different types of clients, such as Web clients, Java clients, and even Visual Basic clients. This is not the case, however, with JSPs, which are used only by Web clients. Another advantage of servlets is their ability to work with binary information, such as images.

When using EJBs, a common practice is to use the home handle of an EJB instance for the cookie value and to store the user's details in an EJB for later reference.

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

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