J2EE Overview

J2EE Servlet 1

J2EE Servlet 2










J2EE Best Practices

J2EE Logging

J2EE Testing

J2EE Deployment

J2EE Development Process

Web and Application Server Interview Questions

What are Application Servers, Web Servers, LDAP servers and Database Servers ?

Web Servers:

Apache, Microsoft IIS, Netscape, Domino etc

Application Servers:

IBM WebSphere, BEA WebLogic, Apache Tomcat, Borland Enterprise Server, Fujitsu Interstage, JBoss, ATG Dynamo etc

Portal servers

Websphere Portal Server, JBoss Portal Server, etc

LDAP Servers

IPlanetís directory server, SiemensDirX etc

Database Servers

IBM DB2, Oracle, SQL Server, Sybase, Informix

What is the difference between a Web server and an application server ?

In general, an application server prepares data for a Web server -- for example, gathering data from databases, applying relevant business rules, processing security checks, and/or storing the state of a userís session. The term application server may be misleading since the functionality isnít limited to applications. Its role is more as retriever and manager of data and processes used by anything running on a Web server. In the coming age of Web services, application servers will probably have an even more important role in managing service oriented components. One of the reasons for using an application server is to improve performance by off-loading tasks from a Web server. When heavy traffic has more users, more transactions, more data, and more security checks then more likely a Web server becomes a bottleneck.

Web Server

  • Supports HTTP protocol. When a 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 an application server.
  • Uses various scalability and fault-tolerance techniques.
  • Application Server

  • Exposes business logic and dynamic content to a 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.
  • What is a virtual host ?

    The term virtual host refers to the practice of maintaining more than one server on one machine. They are differentiated by their host names. You can have name based virtual hosts and IP address based virtual hosts.

    For example:

    A name-based "virtual host" has a unique domain name, but the same IP address. For example, and can have the same IP address and share the same Web server. We can configure the Web server as follows:

    DocumentRoot /web/company1
    DocumentRoot /web/company2

    In this scenario, both and are registered with the standard domain name service (DNS) registry as having the IP address A user types in the URL in their browser. The user's computer resolves the name to the IP address The Web server on the machine that has the IP address, so it receives the request. The Web server determines which virtual host to use by matching the request URL It gets from an HTTP header submitted by the browser with the "ServerName" parameter in the configuration file shown above.

    Name-based virtual hosting is usually easier, since you have to only configure your DNS server to map each hostname to a single IP address and then configure the Web server to recognize the different hostnames as discussed in the previous paragraph. Name-based virtual hosting also eases the demand for scarce IP addresses limited by physical network connections [but modern operation systems support use of virtual interfaces, which are also known as IP aliases]. Therefore you should use name-based virtual hosting unless there is a specific reason to choose IP-based virtual hosting. Some reasons why you might consider using IPbased virtual hosting:
  • Name-based virtual hosting cannot be used with SSL based secure servers because of the nature of the SSL protocol.
  • Some operating systems and network equipment implement bandwidth management techniques that cannot differentiate between hosts unless they are on separate IP addresses.
  • IP based virtual hosts are useful, when you want to manage more than one site (like live, demo, staging etc) on the same server where hosts inherit the characteristics defined by your main host. But when using SSL for example, a unique IP address is necessary.
  • For example in development environment when using the test client and the server on the same machine we can define the host file as shown below:

    UNIX user: /etc/hosts
  • localhost
  • What is application server clustering ?

    An application server cluster consists of a number of application servers loosely coupled on a network. The server cluster or server group is generally distributed over a number of machines or nodes. The important point to note is that the cluster appears as a single server to its clients. The goals of application server clustering are:
  • Scalability: should be able to add new servers on the existing node or add new additional nodes to enable the server to handle increasing loads without performance degradation, and in a manner transparent to the end users.
  • Load balancing: Each server in the cluster should process a fair share of client load, in proportion to its processing power, to avoid overloading of some and under utilization of other server resources. Load distribution should remain balanced even as load changes with time.
  • High availability: Clients should be able to access the server at almost all times. Server usage should be transparent to hardware and software failures. If a server or node fails, its workload should be moved over to other servers, automatically as fast as possible and the application should continue to run uninterrupted. This method provides a fair degree of application system fault-tolerance. After failure, the entire load should be redistributed equally among working servers of the system.
  • Explain Java Management Extensions (JMX) ?

    JMX framework can improve the manageability of your application by
  • Monitoring your application for performance problems, critical events, error condition statistics, etc. For example you can be notified if there is a sudden increase in traffic or sudden drop in performance of your website.
  • Making your application more controllable and configurable at runtime by directly exposing application API and parameters. For example you could switch your database connection to an alternate server. You can also change the level of debugging and logging within the application without stopping the server. You could write a poller, which polls your database at a regular interval as a JMX sevice, so that you can alter the polling interval, stop and start the poller through your server console without having to stop the server.
  • By interfacing JMX to your hardware, database server and application server, health checks can be performed of your infrastructure.
  • Explain some of the portability issues between different application servers ?

    Transaction isolation levels, lazy loading and dirty marker strategies for EJB, class loading visibility etc.

    What is a Portal ?

    A portal is a Web site or service that offers broad range of resources and services like e-mail, forums, search engines, on-line shopping, news, weather information, stock quotes, etc. Portal is a term generally synonymous with the terms gateway or grand entrance into the Internet for many users. E.g.,, etc. A Web portal software allows aggregation of several back-end systems, processes, sites etc brought together through a single portal page. Portals also provide additional services such as single sign-on security, customization (i.e. personalization) etc.

    What are the logical components to consider when building a portal to the Java Portlet specification

    Portal Server:

    is an application, which aggregates portlet applications together in a presentable format to the user. In addition to being a presentation layer, it allows users to customize their views including what portlet applications to show, colors, images etc. Also provides additional services like single sign-on security etc.

    Portlet Container:

    provides a run-time environment to portlets, much in the same way a servlet container provides the environment for servlets. The portlet container manages portlets by invoking their lifecycle methods (init(..), processAction(..), render(..), destroy() etc ). The container forwards requests to an appropriate portlet.When a portlet generates a response, the container sends it to the portal server to be rendered to the user.


    provides content to its calling portal container for the purpose of being displayed on a portal page. Portlets are like servlets but portlets do not generate complete HTML documents. They only generate fragments that are included on the final portal page. Portlet applications are essentially extended Web applications (i.e. a layer on top of servlets). Portlets also share the application context with servlets and JSPs and can even include the output of another servlet or JSP as part of their content. Userís actions are received within a portlet in the form of both action (to respond to userís interactions like search etc) and render methods (to paint the output of the portlet).


    Under the covers the GUI windows News, Stock Quote and Weather shown in the diagram are different applications, developed independently of each other and deployed as individual .war in the portal server.

    How do Portlets differ from Servlets ?

    The Portlet API is capable of using the existing application server infrastructure. You can call an EJB from your portlet, or you can start and participate in a global transaction controlled by your application server. In other words, portlets are Web components like servlets and can do pretty much every thing that a servlet can do except for a few important differences:
  • Portlets do not generate complete HTML documents. Portlets only generate fragments of HTML that are to be included as part of the final portal page. Portlets are not allowed to generate HTML tags like <title>, <head>, <body>,<frame>, <iframe>, <base>, etc. The portal server decides where these tags should go and provides additional <table>, <tr> and <td> tags for each portlet. Portlets can access either servlets or independent JSPs by directly including their output within a portletís rendered output, but only without these offending HTML tags.
  • Portlets are not directly tied to a URL and they use methods such as createActionURL( ..) or createRenderURL( ..) to construct a URL that allows a user to fire actions to render currently executing portlet. You cannot send somebody URL of a portlet but you can send him/her the URL of the portal page containing a portlet.
  • A Portlet can exist multiple times on the same page and the user is given the ability to control what portlets are displayed on his/her page (i.e. known as personalization). Also the user can minimize or maximize each portlet window.

    What are portlet window states and portlet modes ?

    Window states:

    To offer the user the ability to customize portlets, there are special window states like normal, minimized and maximized. A window state determines how much content should appear in a portlet. Normal will display the portletís data in the amount of space defined by the portal application, maximized will display only that portlet in the whole window, and minimized may display only one or two lines of text.

    Portal modes:

    determine what actions should be performed on a portlet. There are three standard modes like View, Edit and Help. Optional modes are possible. The GenericPortlet class defines three empty methods doEdit(..), doView(..) and doHelp(..). Your subclasses can implement any of these methods.
    Furthermore, the portlet can use these states and modes to determine what content it needs to show the user at any given point.

    How do portlets provide customization in addition to window states and portlet modes ?

    To provide customization portlets support preferences, which are name/value pairs that can be assigned an initial value and later tailored to other values based on user preference. Preferences are initially defined within the portletís deployment descriptor file portlet.xml and accessed through the PortletPreferences object, which provides methods to retrieve, change or store preferences. Preferences can also be read-only and also can be verified with validators.

    How would you achieve design flexibility in a portal to cater for different look and feel ?

    normal Website designers know the type and amount of the initial content but portal designers have to design the portal to be flexible enough to meet diverse clientsí and usersí needs. Design flexibility can be achieved by using CSS (Cascading Style Sheets) to avoid hard coding colors and images into the portal so that customers can easily customize (i.e. modify) the look of their portal.

    J2EE Best Practices Interview Questions >>>

    Home Clouds