Samarstan Java Notes
J2EE
Version 0.00 7/10/2003 by Samar
Component Technologies:
- Jsp
- Servlets
- ejb, jms, jca
- misc: JNDI, JTS, JavaMail. Java Corba, JCA,
from Web Services/Webapps
- WebApp Frameworks: MVC, Struts, JSF, WAF
- JAXP, JAXR, JAX-RPO, SAAJ
from webapps: App Servers
- Weblogic, Websphere
from j2se
- 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
- Directives
- <%@ page ... %> ;
<%@ page language="java" %> - always 1st line ofall jsps
- <%@ include ... %>
- <%@ taglib ... %> - custom tags,
<%@ taglib uri="WEB-INF/lib/tag_lib_name.tld" prefix="prefix_name" %>
- Declaration
<%! private int i; %>
- Scriptlet
<% ... %>
- Expressions
<= i %>
- Beans
<jsp:useBean id="id_bean" class="xPackage.xClass" scope="session" />
... <% id_bean.f() %>
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 |
- session
- session.setAttribute("xattribute", i)
- session.getAttribute("xattribute")
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
- > ant = > ant default = > ant compile;
ant war
- > ant compile; ant war
(compile srcs, assemble j2ee module files + war file)
- ant default; ant deploy
- > ant -buildfile f (alt.buildfile, deflt.
build.xml)
- ant compile; ant dist; ant deploy
(compile, make distrib war file, cp to dir)
- erase WEB-INF/classes/*
then again ant to force changes to new files to take effect;
ant recreates the folder struct
<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
J2EE
- Masslight j2ee tutorial : excellent jsp, war tutorial
http://j2ee.masslight.com/Chapter1.html
- J2EE 1.4 Tutorial by Sun
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html ;
1.3 versn:
http://java.sun.com/j2ee/tutorial/1_3-fcs/index.html
- Marty Hall:
"Servlets and JavaServer Pages (JSP) 1.0: A Tutorial" -
http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/
JSP
- O'Reilly OnJava:
http://www.onjava.com - 100's articles.
- Horstmann's eclipse tutorial:
http://www.horstmann.com/bigj/help/eclipse/
Servlets
- "Servlet Essentials" by Stefan Zeiger,
http://www.novocode.com/doc/servlet-essentials/
-
http://java.rrzn.uni-hannover.de/jug/servlets/tutorial/servlet_tutorial.html
http://enterprise.netscape.com/docs/cms/cms_sdk/tutorials/servlets/cert/inventory.html
- Core Servlets and JSP **** full free book
http://pdf.coreservlets.com/
- Simplified Guide to j2ee
http://java.sun.com/j2ee/sdk_1.2.1/techdocs/guides/j2ee-overview/cover.fm.html
- links to books
http://www.maththinking.com/boat/booksIndex.html
- Mastering EJB (*****) by Ed Roman (5M free ebook)
http://www.redbrick.dcu.ie/~robrusk/doc/masteringEJB.pdf
http://latemar.science.unitn.it/Didattica/aa_2003_2004/Web_Programming/Documentation/
- Oreilly Enterprise Java CD Bookshelf
http://book.onairweb.net/computer/oreilly/javaenterprise/index.htm
- EJB Slides ****
http://sern.ucalgary.ca/courses/seng/609.09/W99/Slides/EJB/
- Oreilly "Java Enterprise CD Bookshelf" 1.0 (*******)
http://book.onairweb.net/computer/oreilly/javaenterprise/index.htm
http://ext.rlab.cs.nyu.edu/~jsr/oreilly/jenut/index.htm
http://www.hk8.org/old_web/Java%20Enterprise/
scwcd
- Ken's Notes
http://www.javaranch.com/carl/scwcd/SunCertifiedWebComponentDeveloperStudyGuide.pdf
- Miftah Khan's Notes
http://www.javaranch.com/carl/scwcd/jsp_study_guide.rtf
http://www.javaranch.com/carl/scwcd/servlet_study_guide.rtf
- Michelle's Notes
http://www.javaranch.com/carl/scwcd/WCDStudyNotes-Michelle.pdf
- Alx Dark: Scwcd Study Guide
http://home.earthlink.net/~alxdark/software/wcd-guide/
- Marty Hall's Notes
http://courses.coreservlets.com/Course-Materials/15-Web-Component-Certification.pdf
- Palwai's Links
http://www.geocities.com/r_palwai/scwcd.htm
-
http://builder.com.com/5100-6390-1050043.html
- JBoss & Struts Books
http://www.balcom.ufcg.edu.br/~rodrigor/download/doc/ebooks/jboss/
- Free Books *****
http://books.dimka.ee/
-
free j2ee books
http://aspasia.mm.di.uoa.gr/~rouvas/java/docs/gorgo/java/java_book_1/
-
scea links
http://www.bm-one.com/Se/scea1.html
- Jnagal's scea page links
http://www.stormpages.com/jnagal/
- elephi's secret archive *****
ftp://elephi_javapub:javapub@202.103.69.216/upload*
-
scbcd mock exam (needs userid)
http://jdiscuss.com/Enthuse/jsp/ShowAvailableTests.jsp