Saturday, February 7, 2009

SCEA1.5 - Few Queries

How many tiers are there in J2EE Application ?
J2EE applications have the following tiers: Client (Browsers, Applications, Applets, Mobile clients and so on), Web (presentation tier consisting of JSP as
view and Servlets as controllers), EJB (Business Tier, consisting of EJB and supporting classes), EIS Integration (Java classes that integrate to the
Enterprise Information System tier) and finally the EIS tier (relational databases, XML databases, ERP systems and so on.)

Confused with UserInRole and CallerInRole ?
Servlet - getUserPrincipal() and isUserInRole() - Servlet is called by user so UserInRole comes in servlet code
EJB - getCallerPrincipal() and isCallerInRole() - EJB is called by servlet not by the user directly, so CallerInRole comes in EJB code

What is the use of DAO ?
EJBs are remote objects that consume significant system resources and network bandwidth. You can use Data Access Objects to encapsulate the logic required to
access databases.
Data Access Objects:
Allow EJBs to delegate responsibility for database access and free them from complex data access routines.
Make code more maintainable.
Provide an easier migration path to CMP
Allow you to adapt data access to different schemas and different databases.