Explain the components of J2EE architecture, i.e. Application components, containers and J2EE APIs.J2EE Components:
Application components:
- Every JEE application is made up of different components.
- A component can be defined as software that is self-contained functionality that is a part of JEE application related in terms of classes, files and perform communication with other components.
- The JEE components are applets, application clients are client components.
- Servlets and JSP technologies are referred as web components.
- The EJB components that comprise enterprise beans are referred as business components.
- JEE components are authored using java programming language and compiled just like a simple java desktop applications.
- JEE components are deployed according to the production requirement and managed by the JEE server.
JEE containers:
- All JEE components are installed in the respective containers while deploying the web applications.
- All the components are supposed to be assembled into a JEE application and then deployed in the respective container, before the execution of a web, an enterprise bean or even application client component execution.
Container Types:
- The deployment process is container specific.
- An EJB container manages the execution of all enterprise beans for a specific JEE application.
- The enterprise beans and their container will be run on JEE server.
- A web container is responsible for the execution of all servlets components and JSP for a specific JEE web application.
- These web components and the corresponding container will be run on JEE server.
- The execution of all application client components for a JEE applications is managed / executed by an application client container.
- The application client and their applications run on the client machines.
- A container by name applet container is a web browser.
- The applet container along with Java plug-in combination runs on the client machine.
JEE API:
- In order to run all the JEE SDK for web applications, the JSE SDK is needed. - The JSE SDK provides the entire required core API for writing JEE components and the JVM. - The following are the JEE APIs that are to be used in JEE applications.
1. EJB API - This API enables the fast, simplified distributed application development at enterprise level.
2. JDBC API – Enables the relational database accessibility for java applications.
3. Servlet API – Provides simple consistent mechanism to manage the application at web server level.
4. JSP API - Provides simple and fastest dynamic web page development.
5. JMS API – Provides the mechanism for simple messaging services.
6. Java Transaction API – An interface between transaction manager and the others involved in distributed transaction system.
7. Java Mail API – Provides platform and protocol independent mailing services.Explain the Java Servlets. Explain its lifecycle.- A servlet is a java class that provides a powerful mechanism for developing server side application programs.
- It provides the component-based, platform-independent methods for building any web based applications by overcoming the performance limitations of CGI programs.
- A servlet application can run on any servlet enabled web container.
- It runs completely in a JVM.
- Browser compatibility is not an issue as the servlet run at the server side.
- The set of HTML-based calls can also be accessed by the servlets. For interactive web applications, servlets is the right choice.
Servlet life cycle :
- The servlet life cycle includes four stages:
Loading and Instantiation :
- The servlet container loads the servlet during and startup of a web application and or when the first request is made. The container creates the servlet instances after loading the servlet .
Initialization:
- Soon after the creation of the instance of a servlet, the container invokes the init() method and passes the servlel’s the initialization information to the init() method.
- The init() must be called by the servlet container before performing any requests by the servlet.
Responding for the requests:
- Once the initialization is properly done, the servlet is ready to service the requests.
- The servlet creates separate threads for each and every request.
- The servlet container invokes the service() method which in turn invokes the appropriate doGet() or doPost() methods for handling the requests and sending responses to the client using response objects.
Destroying the servlet:
- If the servlet is not needed for processing the requests, the destroy() method will be invoked by the container.
- This method also invoked only once through out the life cycle of a servlet.
- Invoking the destroy() method indicates that the servlet container not to send any requests for the service and the servlet will release the resources that are associated with it.
- JVM will claim the memory with the resources for garbage collections.Explain JSP. Describe JSP lifecycle.Java Server Pages (JSP):
- A JSP is used for the development of dynamic web pages.
- JSP provides the server side scripting support for creating web applications that uses database.
- JSP encourages the developers to directly insert the java code into .jsp file.
- This process is very simple to develop and maintain.
- JSP are loaded into the web servers’ memory as soon as receiving the request in the very first time.
- The subsequent calls are served within a very short span of time.
- The usage of JSP in combination with JDBC is very easy to efficient to develop the database specific applications.
- JSP are platform independence as java is and any JSPage can be ported to any platform.
JSP Life Cycle:
- JSP services are the requests from clients as that of a servlet.
- At the time of the JSP request mapping, the request is handled by a special servlet.
- This servlet first checks whether the first JSP servlet is older than the JSP.
- If it is so, the translation of JSP into servlet class and compilation of this class is done. And then the request is handled by the servlet like an ordinary servlet.Explain the following java graphical interface framework.1. Abstract windows toolkit (AWT) 2. Swing 3. Standard widget toolkit (SWT)
1. Abstract Windows Toolkit (AWT):
- AWT provides the interface between the user and different windowing toolkits, such as buttons, checkboxes, radio buttons and menus etc.
- AWT establishes the connection between the java applications and the Graphical User Interface(GUI).
- It is adequate to develop many applications. For example, the menus on the TV sets and other remote controls were developed using AWT (may be with Swings).
- AWT uses the basic GUI operating systems controls.
- AWT is a part of Java Foundation Classes(JFC).
2. Swing:
- A Swing toolkit includes much more rich set of GUI tools compared to AWT.
- Few more high-level component sets are available in Swing such as (tree view, list boxes, tabbed panes, pop up windows, tooltips, icons).
- To leverage cross-platform capabilities, Swing supports more similar look and feel of the components.
- Swing is more flexible and all the swing components are light weight, thereby reduces the loading time.
3. Standard Widget Toolkit (SWT):
- SWT is an open source widget tool kit for developing rich, efficient and portable GUI applications.
- It was originally developed by IBM and being maintained by Eclipse Foundation along with Eclipse IDE.
- It is an alternative to AWT and Swing.
- To display the elements, it implements the operating system GUI libraries by using Java Native Interface.
- The SWT applications are portable and unique for each platform.
- The need of SWT is to provide a common API for accessing different operating system / platform specific widgets.
- The goal for designing of SWT is high performance, native OS look and feel, and platform integration.
- Swing on the other hand, designed to allow for a highly customizable look and feel that is common across different platforms.List out components by AWT? Explain each in brief.1. Button
2. Canvas
3. Choice
4. Checkbox
5. Container i. Panel ii. Scrollpane iii. Windows
6. Label
7. List
8. Scrollbar
9. TextComponent i. TextArea ii.TextField
1. Button:
- A component that is used to display the command button on the canvas. By clicking on the button, an action is performed.
2. Canvas:
- A blank rectangular area on the screen on which an application can draw other components or on which an action can be trapped.
3. Choice:
- A component that pop ups a menu of choices and the current choice is displayed as the title of the menu.
4. Checkbox:
- A component that represents a check box that represents either true or false state. If the option is true, then a tick mark appears in the box.
5. Container:
- A component that can contain another set of components. All these components are tracked in a list.
6. Panel:
- It is one of the simplest container classes. A panel provides space to place other components including other panels.
7. Scrollpane:
- A container which implements the scrolling that can be horizontal or vertical for a child component.
8. Windows:
- Represents a top level window that has no borders and no menubar. A window must have a frame, a dialog box or another window as its owner window.
9. Label:
- A component to place text in a container that is displayed as read only text containing a single line
10. List:
- A component that specifies a list of items of text with a provision for the user to select a single or multiple items.
11. Scrollbar:
- A component that is used basically for moving the visible area, where the components / contents are not enough to appear in a single screen page.
12. Text Components:
- TextArea: A component where multiple lines of text can be typed / visible. It can make to appear as read-only area or to appear for editing. - TextField: A component where a single line of text can be typed / visible.
|