(We are now java.net community
member. Please click the above button in order to join as a
individual member.)
- Class #1 (10/13/2003,
Monday - online
class only):
Advanced
Web-tier technologies: Custom tags and JSP 2.0
- A few words from Sang Shin
- In this class and the subsequently following
class, we are
going to learn advanced Web-tier
technologies such as JSP custom tags and JSTL. We will also learn newly
introduced features in Servlet 2.4 and JSP 2.0, which are now part of
J2EE 1.4.
- I realize that learning all the features of
JSP 1.2, 2.0,
and JSTL would be too much to bite in a single 3-hour session. So
I divided them into 2
sessions. The class #1 deals with just custom tags and
class #2 deals with JSTL and MVC pattern.
- I found that Marty Hall's approach of
explaining custom tags
in his book "more Servlets and JavaServer Pages" quite effective.
He explains custom tags based custom tag usage patterns in which a very
simple custom tag is introduced first and then gradually more
sophisticated custom tags are then explained. And in each usage
pattern, he shows example tag handler class, TLD file, and JSP
page. The JSP 1.2 presentation slides are created based on his
approach
and sample codes.
- For JSP 2.0 features, Java WSDP 1.3 tutorial
is used for
creating
presentation slides.
- Prerequisite
- Basic understanding on Servlet and JSP
technologies. If
you are new to Servlets and JSP, please study the following Servlet and
JSP basics material from "basic" J2EE Programming (with Passion!)
course first
- Presentation
materials
- Pre-class
reading materials (please make sure you read "must to read"
items before coming to class)
- Hands-on
lab exercise/homework
material
- If you
have not done
yet, please download Java
WSDP 1.3 and Java
WSDP 1.3 Tutorial (yes, they have to be downloaded
separately)
before you go to
the next step.
- Java WSDP 1.3 tutorial zip file can be
unzipped
anywhere.
- I unzipped it under
<jwsdp-1.3-install> directory,
which is, under my Java Desktop System, /home/sang/jwsdp-1.3. So
the after unzipping the tutorial, I see
/home/sang/jwsdp-1.3/jwstutorial13 directory. And
the screen shots are made with this directory structure.
- Some homeworks are using features
introduced in JSP 2.0,
which is supported only in JWSDP 1.2 and after.
- Please make sure you follow setup
instruction of running
Java
WSDP 1.3 tutorial as described in "About
the Examples" section of Java
WSDP 1.3
Tutorial,
especially setting up path and modifying
build.properties file accordingly. Otherwise, you will experience
some odd problems.
- Download the custom
tag
hands-on lab exercise zip
file and then unzip it under
<jwsdp-1.3-tutorial-install-directory>/jwstutorial13/examples/web
directory
- These sample codes are originally from Marty
Hall's custom
tag sample code
- The following modifications are made to
the original
sample codes
- Each sample code has a different root
directory
- Ant build.xml script is provided for each
sample code
- *.tld file is moved to root/WEB-INF
directory
- In order to build and deploy the sample
codes, please do the
following
- Start Tomcat of Java WSDP 1.3 (startup.sh
for
Solaris/Linux, startup for
Windows)
- cd
<jwsdp-1.3-tutorial-install>/jwstutorial13/examples/web/simpletag
(or different sample code directory)
- ant build
- ant install
- ant list (to check if the "simpletag" Web
application is in
"running" state)
- Then access the JSP page from a browser -
you can go to
"http://localhost:8080/manager/html " (Tomcat application manager
Web
application) from your browser first and then select and click on the
Web
application, for example, "/simpletag", and then click on the JSP page.
- If somehow your application is not in
"running" state after
installation (that is, in "stopped" state), please use the following
information for debugging
- If you are using Windows, please make sure
you set the
tutorial.home as following:
- Good : tutorial.home=C:/jwsdp-1.3
- Bad: tutorial.home=C:\jwsdp-1.3
- Homework assignment - HW1A (Estimated
time: 1 to 2 hours)
- Objective
- Getting familiar with building,
configuring, and deploying
a tag library
- Exercise custom tag usage examples as
described in the
presentation material
- Tasks
- Download Hands-on lab exercise material
mentioned above and
build and run all the sample codes as shown in the presentation material
- Things to be submitted
- Nothing needs to be submitted
- Helpful hints
- Homework assignment - HW1B (Estimated
time: 2 to 3 hours)
- Objective
- Exercising "Optionally including body
content" custom tag
usage pattern
- Getting a value of a request parameter
inside a tag handler
- Understanding the source and build
directory structures
- Creating a TLD file
- Tasks
- Build a tag library which contains a tag
handler that
displays a body content depending on the value of an input parameter
- Display a heading "Java Passion Custom
Tag Test" first
- If the value of input parameter "city" is
"Boston",
display "I love Boston Red Sox!"
- Otherwise, do not display anything
- Things to be submitted
- Helpful hints
- Take a look at "DebugTag" example code as a
guide. You
might want to create a directory called something like "hw1b", which
then contains similar subdirectory structure as the DebugTag example.
- Homework assignment - HW1C (Estimated
time: 1 to 2
hours)
- Objective
- Exercising "Manipulating the tag body"
custom tag usage
pattern
- Tasks
- Modify the HW#1B code as following
- If the value of input parameter "city" is
"Boston",
display "I love Boston Red Sox!"
- Otherwise, display the string "I love
Boston Red Sox!" in
reserve order - "!xoS deR
notsoB evol I"
- Things to be submitted
- Helpful hints
- Take a look at "Manipulating the Tag Body"
example code as
a guide
- Homework assignment - HW1D (Estimated time:
1 to 2
hours)
- Objective
- Getting familiar with all the new features
introduced in
JSP 2.0
- Getting familiar with build environment of
JSP 2.0 sample
codes
- Tasks
- Play around with all the JSP 2.0 Examples
that come with
Java WSDP 1.2 as following
- Start Tomcat of Java WSDP (startup.sh for
Solaris/Linux, startup for
Windows)
- From your browser, go to
"http://localhost:8080/"
- Select "JSP examples"
- Try "Execute" and then see the source by
clicking on
"Source"
- Build and run the same JSP 2.0 Examples
above as following
- cd
<jwsdp-1.3-tutorial-install>/jwstutorial13/examples/web/jsp2
- ant build (for creating unpacked form) or
ant package
(for creating *.war file)
- ant install (for temporary deployment) or
ant deploy (for
permanent deployment)
- ant list (to check if the /jsp2 is in
"running" state)
- Then
access the JSP page from a browser - you can go to
"http://localhost:8080/manager/html " (Tomcat application manager
Web
application) from your browser first and then select "/jsp2", then
drill down to actual JSP page and click on it
- Build and run iterator sample code that
comes with Java
WSDP 1.2 (or 1.3)
- Start Tomcat of Java WSDP (startup.sh for
Solaris/Linux, startup for
Windows)
- cd
<jwsdp-1.3-tutorial-install>/jwstutorial13/examples/web/iterator
- ant build
- ant install
- ant list (to check if the Web application
is installed
correctly)
- Then access the JSP page from a browser -
you can go to
"http://localhost:8080/manager/html " (Tomcat application manager
Web application) from your browser first and then select "/iterator".
- Whenever you modify the code, please do
"ant remove" to
remove previously installed Web application, and then do "ant build"
and "ant install" as described above
- Things to be submitted
- Nothing needs to be submitted
- Homework assignment - HW1E (Estimated time:
1 to 2
hours)
- Objective
- Exercising basic arithmetic and comparison
functionality
of JSP 2.0's Expression Language (EL)
- Tasks
- Modify and redeploy the following JSP pages
under
<jwsdp-1.3-tutorial-install>/jwstutorial13/examples/web/jsp2/web/el
directory
- add EL arithmetic expression "${123+456}"
to
basic-arithmetic.jsp
- add EL comparison expression
"${123>456}" (should
result to "false") to basic-comparisons.jsp
- Things to be submitted
- Helpful hints
- Homework assignment - HW1F (Estimated time:
1 to 2
hours)
- Objective
- Accessing implicit objects via JSP 2.0's
Expression
Language (EL)
- Tasks
- Modify and redeploy implicit-objects.jsp
under
<jwsdp-1.3-tutorial-install>/jwstutorial13/examples/web/jsp2/web/el
directory or create a new JSP file to access and display the following
HTTP header fields
- host
- accept
- authorization
- cookie
- Things to be submitted
- Helpful hints
- Look at the blue sky outside and take a
deep breath
- Homework assignment - HW1G (Estimated time:
1 to 2
hours)
- Objective
- Exercising function capability of JSP 2.0's
Expression
Language (EL)
- Tasks
- Add the following new function to
Functions.java under
<jwsdp-1.3-tutorial-install>/jwstutorial13/examples/web/jsp2/src/jsp2/examples/el
directory
- public static String lowercase( String
text ) {return
text.toLowerCase(); }
- Modify functions.jsp under
<jwsdp-1.3-tutorial-install>/jwstutorial13/examples/web/jsp2/web/el
to display newly added function above
- Things to be submitted
- Helpful hints
- Look at the blue sky outside and take a
deep breath
- Homework assignment - HW1H (Estimated time:
1 to 2
hours)
- Objective
- Building and deploying a SimpleTag Handler
of JSP 2.0
- Tasks
- Rewrite HW#1B using SimpleTag handler
- Things to be submitted
- Helpful hints
- Create simpletag handler called something
like "hw1h.java"
in the same directory where other simple tag handlers reside, <%@
attribute name="title" %>/src/jsp2/examples/simpletag
- Modify the "jsp2-example-taglib.tld" file
which resides
under
<jwsdp-1.3-tutorial-install>/jwstutorial13/examples/web/jsp2/web/WEB-INF
directory accordingly
- Homework assignment - HW1I (Estimated time:
1 to 2
hours)
- Objective
- Build and deploy a simple tag file
- Tasks
- There is a mistake in
<jwsdp-1.3-tutorial-install>/jwstutorial13/examples/web/common/targets.xml
file. Please change line number 36 of this file from
<fileset dir="web"> to <fileset dir="web/WEB-INF/tags">
like following
- <copy
todir="${build}/WEB-INF/tags">
<fileset dir="web/WEB-INF/tags">
<include name="**/*.tag"
/>
</fileset>
</copy>
- Modify the following two files so that
"subtitle" attribute
gets displayed for each table
- <jwsdp-1.3-tutorial-install>/jwstutorial13/examples/web/jsp2/web/tagfiles/panel.jsp
- <jwsdp-1.3-tutorial-install>/jwstutorial13/examples/web/jsp2/web/WEB-INF/tags/panel.tag
- Things to be submitted
- How to submit homeworks
of class#1
- Create a zip file that contains the source
files of all
the homeworks of class #1 except the ones that says "nothing needs to
be submitted" and submit it as described in How
to submit homeworks for advanced class
- Class #2 (11/03/2003,
Monday): JSTL (JSP
Standard Tag
Library), MVC architecture
- Class #3 (11/10/2003,
Monday): Struts
Basics
- Class #4 (12/01/2003,
Monday):
Advanced Struts
- Class #5 (12/22/2003,
Monday):
JavaServer Faces (JSF)
- Class #6(01/26/2004,
Monday):
Advanced JSF
- A few words from Sang Shin
- Since we
were able to touch only the basic features of JSF in class #5, I
decided
to continue to talk about JSF in class #6 with more advanced topics
mentioned below.
- Even with extra 3 hours, however, I don't think
we can cover them all.
- In the face-to-face class, in addition to the
presentation, we
will also walk through the cardemo sample code in rather detail going
through each code page by page
- You can do your homework using either Java WSDP
1.3 or J2EE 1.4
SDK.
My recommendation is to use J2EE 1.4 which integrates all the
functioanlity of Java WSDP 1.3 and more. Insructions on both are
provided. (April, 2004)
- Presentation
materials
(Being modified to be V1.0 compliant)
- Advanced Features of JSF (2 hours):
- Walkthrough of CarStore JSF application(1
hour):
- Building Custom UI component: (1 hour)
- JSF and Struts: (1 hour) (Craig McClanahan's
Nov. 2003
presentation)
- JSF Tools (Sun Java Studio Creator,
Faces-console): (30 minutes)
- Work-in-progress
Presentation
materials
- Walkthrough of JSF programming APIs:
- (PDF
slides with speaker notes) (PDF
1 slide
per page) (StarOffice
file)
- JSF Testing, Debugging, Logging, and
Performance:
- (PDF
slides with speaker notes) (PDF
1 slide
per page) (StarOffice
file)
- Pre-class
reading material
- Homework
assignment
- Objectives
- Tasks
- Things to be submitted