Samarstan Java Notes

J2EE

Version 0.00 7/10/2003 by Samar


    Component Technologies:
  1. Jsp
  2. Servlets
  3. ejb, jms, jca
  4. misc: JNDI, JTS, JavaMail. Java Corba, JCA,
    from Web Services/Webapps
  5. WebApp Frameworks: MVC, Struts, JSF, WAF
  6. JAXP, JAXR, JAX-RPO, SAAJ
    from webapps: App Servers
  7. Weblogic, Websphere
    from j2se
  8. jdbc, corba (ejb predecessor) (cf. j2se notes)
J2EE (Java 2 Enterprise Editn) = spec for developg enterprise + distributed apps (by Sun). incl j2se comptts (jdbc, corba) a platform is a combination of hardware and software necessary to run applications

I. JSPs

a. syntax

Tools: DrumBeat 2000 JSP (win), alt. html template engines: xmlc (enhydra.org) , webmacro(webmacro.org), TeaServlet, freemarker, velocity, m7.com (jsp, struts ed)

b. implicit objects
Implicit object
Description
request  Represents the client’s request. An implementation of javax.servlet.http.HttpServletRequest
response Represents the JSP page’s response. An implementation of javax.servlet.http.HttpServletResponse
pageContext Represents the objects and attributes associated with a page. A subclass of javax.servlet.http.pageContext
session Represents the session associated with the request. An implementation of javax.servlet.http.HttpSession
application Represents the application associated with the request. An implementation of javax.servlet.ServletContext 

xProject
 |
 +- build.xml
 +- f.jsp 
 +- WEB-INF
      |
      +- web.xml 
      +- f.tld
      +- classes
           +- com
               +- dupont
                    +- texas
                         +-- f.java 
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
  "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>
 <taglib>
    <taglib-uri> /WEB-INF/tagExampleLib.tld </taglib-uri> 
    <taglib-location> /WEB-INF/tagExampleLib.tld </taglib-location> 
  </taglib>
</web-app>

II. Servlets Servlets are pure Java objects that generate HTML by writing it to a stream


I. ejb

a. servlets

a. ant


<project name="MyStrutsProject" default="dist" basedir="."> <description> struts ant buildfile </description> <property name="xsrc" location="WEB-INF/src"/> <!-- set global properties for this build --> <property name="xbuild" location="WEB-INF/classes"/> <property name="xdist" location="WEB-INF/dist"/> <target name="init"> <tstamp/> <!-- create time stamp --> <mkdir dir="${xbuild}"/> </target> <target name="compile" depends="init" description="compile srcs"> <!-- Compile the java code from ${src} into ${build} --> <javac srcdir="${xsrc}" destdir="${xbuild}" classpath="WEB-INF/lib"/> </target> <target name="dist" depends="compile" description="make war"> <war warfile="f-${DSTAMP}.war" webxml="web.xml"> <fileset dir="."> <!-- include all JSPs in root level --> <include name="*.jsp"/> <include name="*.xml"/> </fileset> <lib dir="./WEB-INF/lib"> <include name="*.jar"/> </lib> <!-- include all tag libraries in WEB-INF, but not web.xml (that's handled separately) --> <webinf dir="WEB-INF/"> <include name="*.tld"/> </webinf> <classes dir="./WEB-INF/classes"/> <!-- include all compiled classes --> </war> </target> <target name="deploy"> <!-- Copy the war file to the JBoss deploy directory --> <copy file="f.war" todir="."/> </target> <target name="all" depends="dist,deploy"/> </project>

References