javascript
Brief description  about Online courses   join in Online courses
OR

J2EE Basics

Rahul  Dutta
Rahul Dutta
IT Software

J2EE-J2EE is yet another acronym in the world of computing. This one stands for Java 2 Platform, Enterprise Edition. Its significance will become clear once we trace its lineage. First of all, Java is a programming language developed by Sun Microsystems, one of the giants of the industry. The Java Platform is a virtual machine, a processor look-alike that translates computerized instructions into functions.

J2EE application not only a web-based It depends on type of application that client wants. A J2EE application can be web-based or non-web-based. if an application client executes on the client machine, it is a non-web-based J2EE application. The J2EE application can provide a way for users to handle tasks such as J2EE system or application administration. It typically has a graphical user interface created from Swing or AWT APIs, or a command-line interface. When user request, it can open an HTTP connection to establish communication with a servlet running in the web tier.

technologies are included in J2EE -The primary technologies in the J2EE platform are:

* Java API for XML-Based RPC (JAX-RPC)
* JavaServer Pages
* Java Servlets
* Enterprise JavaBeans components
* J2EE Connector Architecture
* J2EE Management Model
* J2EE Deployment API
* Java Management Extensions (JMX)
* J2EE Authorization Contract for Containers
* Java API for XML Registries (JAXR)
* Java Message Service (JMS)
* Java Naming and Directory Interface (JNDI)
* Java Transaction API (JTA)
* CORBA
* JDBC data access API

J2EE clients-
J2EE clients are those applications, components, systems, and services that access the J2EE environment to fulfill a request or access a service. Depending upon the scope and horizons of a given enterprise J2EE environment, they can range from simple HTTP requests to complex interactions between several J2EE servers across the networks.

Types of J2EE Client Access..............

Accessing business logic services in EJB
Accessing presentation logic services
Accessing enterprise services
Accessing EIS services through J2EE

Example: Let us say we have a Siebel CRM system in the back end, and we access the resources through messaging systems/Siebel adapters. It is possible to construct access gateways inside J2EEâ by making use of JMS, EJBs, and other Java libraries so that Siebel resources can be accessed by a wide variety of Java clients and other applications in a consistent manner

Java Servlet API-Java Servlet API is that Application Program Interface (API), which defines and describes the contracts between servlets and servers. That means, it contains the set of programs and standard instructions to develop a proper access between a servlet and the server. Servlet API is a part of the official J2EE API. This API contains 2 packages with the extension javax. They are as follows.

·        Package javax.servlet

·        Package javax.servlet.http

Package javax.servlet:

Package javax.servlet deals with the contracts between a servlet class and the runtime environment offered for an instance of the class, within the servlet container.

It contains a set of classes and interfaces. Some important classes and interfaces like, Class GenericServlet which implements Interface Servlet. Apart from that, interfaces like Filter, RequestDispatcher, ServletRequest, ServletResponse, etc. and classes like ServletInputStream, ServletOutputStream, etc are also belong of this package. It also contains 2 exceptions, and they are ServletException and UnavailableException.

Package javax.servlet.http:

Package javax.servlet.http deals with the contracts between a servlet class, which is running under HTTP protocol and the runtime environment offered for an instance of the class, within the servlet container.

It also contains some important classes and interfaces. Some of them are, Interfaces like HttpSession, HttpServletResponse, HttpServletRequest, HttpSessionBindingListener, etc and classes like Cookie, HttpServlet (which implements Interface Servlet of javax.servlet package), etc.

Uses of Servlet API:

Management of Servlet life cycle.

It provides access to servlet context.

It also provides some utility classes.

And last but not least, it also provides classes to handle HTTP protocol.

GenericServlet-As the name suggest, it's a generic servlet and doesn't depend upon a particular protocol. It implements Servlet and ServletConfig interfaces and contains all the base code required by a servlet to maintain its life-cycle. As per the specification, Servlets are not restricted to a particular protocol and we can extend this class for any protocol, but we don't normally do that. Instead we use the already defined subclass (HTTPServlet) of this class specific to the HTTP protocol.

This class contains one abstract method called 'service(ServletRequest request ServletResponse response)'. We just need to define that methods in case we use this class to create servlets. This method is called by the servlet container on receipt of the request for that particular servlet and after that this method takes care of preparing the response for the incoming request.

Signature: public abstract class GenericServlet extends java.lang.Object implements Servlet, ServletConfig, java.io.Serializable

GenericServlet defines a generic, protocol-independent servlet.

GenericServlet gives a blueprint and makes writing servlet easier.

GenericServlet provides simple versions of the lifecycle methods init and destroy and of the methods in the ServletConfig interface.

GenericServlet implements the log method, declared in the ServletContext interface.

To write a generic servlet, it is sufficient to override the abstract service method.

Write your comment now
 
Reader's comments(2)
1: What is the difference between java and j2ee?
Posted by:Sanjay - 08 Aug, 2012
2:
Java is a programming language.
Where as J2EE is the advanced technology for java where u can design webpages singleton softwares etc.
Kumar Manoj Replied to: Sanjay - 08 Aug, 2012