J2EE Tutorial - Introduction
|About the author (Published in DeveloperIQ - www.developeriq.com Magazine)|
There is a great demand for experienced J2EE professionals now in the market and students and programmers from other languages want to know whether J2EE is Java atall or something else. This tutorial is a conceptual presentation of what & why of J2EE. (It is better for aspiring Java professionals to be forewarned that the Industry expects sound knowledge of EJB, JAX and Struts ..as well as hands on experience in Application servers like WebLogic /WebSphere as a MINIMUM! .It is also important to remember that jdk1.4 is the current version with a lot of new features and jdk1.5 is expected shortly. Moreover, Security in computing is assuming great importance and the candidate should have sound knowledge about java security.)
J2EE is not the Java , that comprises of topics like Applets, Console- mode programs, Standalone GUI, Multithreading, Graphics,Exception-handling, String processing, IO Streams, Java Beans in BDK, Swing etc.( topics covered in great detail by books on Core Java , such as 'Java2 -complete reference' by Schildt.,with not a word anywhere on that staple of Computing world of any type (ie) DataBase access!)
The title of the book was appropriate some 7 years back! That is why we are puzzled and dismayed that the Java that we studied so 'completely' is so basic and so incomplete!..To be fair, even with the arrival of jdk1.1,some authors like Bill McCarty ('Java ..Distributed Objects') and Jaworsky ('Java2 Unleashed') had a better perspective about the Enterprise potential & orientation of Java and wrote accordingly. However, they are being mentioned only now in curricular circles. after what they wrote so well has sadly become , partly outpaced..This is not to say that Core Java is useless. As the name suggests, it is the core and absolutely essential . But, Java has always been a language for the Web and Enterprise. Without that essential paradigm shift from desktop/LAN to the sprawling WEB & huge enterprise data, it is very difficult to appreciate the modern trends and why there is so much clamour for J2EE (despite the supposed challenge from DotNet). The only topics that could bridge the Core and Enterprise Java are Sockets & Beans.
This, however, is pretty long journey and this 'short' tutorial cannot cover all the details. The readers are equested to refer to the books mentioned towards the end to get more details.
J2EE ( Java 2 -Enterprise Edition) is a basket of 12 inter-related technologies , which can be grouped as follows for convenience.:
(Web-Server & support Technologies )
1) JDBC ( Java Database Connectivity)
3) JSP (Java Server Pages)
4) Java Mail
5) RMI (Remote Method Invocation)
6) Corba-IDL ( Corba-using Java with OMG-IDL)
7) RMI-IIOP (Corba in Java without OMG-IDL)
8) EJB (Enterprise Java Beans)
Group-3 ( Supporting &
Advanced Enterprise technologies)
9) JNDI ( Java Naming & Directory Interfaces)
10) JMS ( Java Messaging Service)
11) JAVA-XML ( such as JAXP, JAXM, JAXR, JAX-RPC, JAXB, and XML-WEB SERVICE)
12) Connectors ( for ERP and Legacy systems).
J2EE is essentially about Distributed Objects Technology, which is defined as invoking a method on an object residing in a remote machine as if it were local to the invoking program. The Distributed Object may be based on RMI or IDL or RMI-IIOP or EJB.
The invoking program can be a standalone mode java program. But , if this were so, it presents two problems. The first problem is that it requires JDK to have been installed in each end-user's machine.This is not a correct assumption because, the only thing that we can be sure of is that the end-user has a browser.
Secondly, even with JDK installed in the end-user machine, the java program has to be distributed to each client personally.. This is hardly a practical proposition, if we want our program to be useful to lakhs of end-users out there.
Applets, are a possible solution. An applet is a java class file embedded in HTML document, downloaded from the web server and executed in the end-user's browser.( The browser should be java-enabled). With built-in sandbox security, Applets made program distribution very easy and elegant.
However, Applets also had two problems. First, standard browsers like InternetExplorer(Microsoft) and NetscapeNavigator (NetscapeCorporation) did not implement JDK fully. This required a java-plug in from Sun.This was clumsy. Secondly, java applets, except in very simple cases, downloaded the classes from the server and though this is a remarkably powerful feature, it also meant that the process was a heavy one and entailed delay in downloading.
For these reasons, Applets also ceased to be the recommended method. That is why Sun developed the Servlets technology. Servlets are java class files , execeuted in server and the resulting html sent to the end-user's browser. Now, at one stroke , it solved many problems.
1) We no longer had to instal JDK in end-user's machine.
2) We need not have a java-enabled browser at the user's end.
3) As the result was sent as html only to the browser, it is lightweight & very fast.
But, this creates a different problem! A WebServer is just for delivering documents as requested by the user. It need not have any scripting features. Various Webservers have built in facilities for executing CGI and CGI like programs. For instance, Personal WebServer has built in feature for executing ASP which uses VBScript. Apache server provides PERL & PHP. Similarly , JavaWebServer provides Servlet engine and JSP engine. Realising that Apache is the leading WebServer in Internet world, Sun collaborated with Apache Foundation and created the Tomcat engine. We must remember that not any web server can execute a servlet.. So, the correct method of invoking the function on a remote object in remote server is through a servlet. The modern practice is to have a thin client.(ie) the end user has just a browser like InternetExplorer or Netscape Navigator. He downloads an HTML form and invokes a servlet or JSP through the form.
If Distributed Objects are not involved, the servlet/jsp does the processing in web server itself and sends the result to the browser. For Distributed Computing , however, the servlet program in the web-server is the client-side for the Distributed Object computing.It invokes the method of the remote object in the Remote Server. ( it may be RMI/IDL/RMI-IIOP/EJB).The result is sent to the end-user's browser. . All this may be very dense fog right now but will clearup as we progress.
With these introductory remarks, let us now take up the technologies one by one.
Servlets & JSP are Web-server technologies.( Distributed Objects Technologies are the more advanced stage...covered in second group) In most of the cases the requirement is that a database is to be accessed either for queries or for modifications . So we use a jdbc program in the webserver and access the database & send the result to the user's browser.
Apart from this , it is also very useful to be able to send email through the server. These two opeartions (ie) database operation & mailing are essential applications in webserver. That is why JDBC & JavaMail have found a prominent place in the first group of J2EE technologies.
JSP , is a technology which tries to separate the code from the presentation.( However, new developments like JSTL (Java Standard Template Library) & Struts have appeared which insist on much higher degree of separation between code & presentation.JSP-2 is awaited and it aims at total elimination of java code anywhere in the JSP page!..something that ASP.NET has already achieved!).
Recommend the tutorial