Q 01: What is J2EE? What are J2EE components and services?
A 01: J2EE (Java 2 Enterprise Edition) is an environment for developing and deploying enterprise applications. The J2EE platform consists of J2EE components, services, A pplication Programming Interfaces (APIs) and protocols that provide the functionality for developing multi-tiered and distributed Web based applications.
Q 02: Explain MVC architecture relating to J2EE?
A 02: This is also a very popular interview question. MVC st ands for Model-View-Controller architecture. It divides the functionality of displaying and maintaining of the data to minimise the degree of coupling (i.e. promotes loose coupling) between components.
Q 03: What is the difference between a Web server and an application server? SF
Supports HTTP protocol. When the Web server receives an HTTP request, it responds with an HTTP response, such as sending back an HTML page (static content) or delegates the dynamic response generation to some other program such as CGI scripts or Servlets or JSPs in the application server.
Uses various scalability and fault-tolerance techniques.
Exposes business logic and dynamic content to the client through various protocols such as HTTP, TCP/IP, IIOP, JRMP etc.
Uses various scalability and fault-tolerance techniques. In addition provides resource pooling, component life cycle management,
transaction management, messaging, security etc.
Provides services for components like Web container for servlet components and EJB container for EJB components.
Q 04: What is the difference between CGI and Servlet? SF
(Common Gateway Interface)
Traditional CGI creates a heavy weight process to handle each http request. N number of copies of the same traditional CGI programs is copied into memory to serve N number of requests.
Spawns a lightweight Java thread to handle each http request. Single copy of a type of servlet but N number of threads (thread sizes can be configured in an application server).
In the MVC architecture, servlets process requests and select JSP views. So servlets act as controller. Servlets intercept the incoming HTTP requests from t he client (browser) and then dispatch the request to the business logic model (e.g. EJB, POJO – Plain Old Java Object, JavaBeans etc). Then select the next JSP view for display and deliver the view to client as the presentation (response). It is the best practice to use Web tier UI frameworks like Struts, JavaServer Faces etc, wh ich uses proven and tested design patterns.