Introduction To Java Applications
Introduction To Java Applications
Introduction To Java Applications
Java:
J2SE: Java 2 Platform, Standard Edition.
Java API, JDBC, Swing etc.,
J2EE: Java 2 Platform, Enterprise Edition.
Servlets, JSP, EJB etc.,
J2ME: Java 2 Platform, Micro Edition.
Designed for embedded systems, mobile Devices, Card Technology.
Web Application:
A Web Application always includes the following files:
A servlet or JSP page, along with any helper classes.
A web.xml deployment descriptor, a J2EE standard XML document that
configures the contents of a WAR file.
Web Applications may also contain JSP tag libraries, static .html and image files,
supporting classes and .jar files, and an ibm-web.xml deployment descriptor,
which configures Web sphere Server-specific elements for Web Applications
/WEB-INF/web.xml
The Web Application deployment descriptor that configures the Web
Application.
/src
Contains server-side java source code such as HTTP servlets and utility
classes.
/classes
Contains server-side classes such as HTTP servlets and utility classes.
/WEB-INF/lib
Contains .jar files used by the Web Application, including JSP tag libraries.
Below figure shows the basic structure of a Web application:
EJB Applications:
Enterprise JavaBeans (EJBs) are reusable Java components that implement
business logic and enable you to develop component-based distributed business
applications. EJB modules are packaged as archive files having a .jar extension,
but are generally deployed as exploded archive directories. The archive file or
exploded archive directory for an EJB contains the compiled EJB classes, optional
generated classes, and XML deployment descriptors for the EJB.
All EJB’s must be packed ( or exploded ) in a file called as JAR file ( Java Archive)
and the structure of JAR is as follows:
Enterprise Application:
An Enterprise Application consists of one or more of the following J2EE
applications or modules:
Web Applications
Enterprise Java Beans (EJB) modules
Resource Adapter modules
An Enterprise Application is packaged as a JAR file with an .ear extension,
but is generally deployed as an exploded EAR directory. An exploded EAR
directory contains all of the JAR, WAR, and RAR modules (also in exploded format)
for an application as well as the XML descriptor files for the Enterprise Application
and its bundled applications and modules.
A key file that defines each type of deployment unit is its XML deployment
descriptor. The deployment descriptor is an XML document that defines certain
runtime characteristics for the application or module.
<web-app>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>mypackage.HelloServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/HelloServlet</url-pattern>
</servlet-mapping>
</web-app>
<ejb-jar>
<enterprise-beans>
<message-driven>
<ejb-name>MessageBean</ejb-name>
<ejb-class>samples.mdb.ejb.MessageBean</ejb-class>
<transaction-type>Container</transaction-type>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
</message-driven-destination>
<resource-ref>
<res-ref-name>jms/QueueConnFactory</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</message-driven>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>MessageBean</ejb-name>
<method-intf>Bean</method-intf>
<method-name>onMessage</method-name>
<method-params>
<method-param>javax.jms.Message</method-param>
</method-params>
</method>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
<application>
<module>
<java>test-client.jar</java>
</module>
<module>
<ejb>test-ejb.jar</ejb>
</module>
<module>
<web>
<web-uri>test.war</web-uri>
<context-root>test</context-root>
</web>
</module>
<library-directory>lib</library-directory>
</application>