SlideShare a Scribd company logo
1 of 62
JavaServer Pages™ /Servlets
 and Web Application Frameworks

Doris Chen, Ph.D
Staff Engineer          This box provides
                        space for call to

Sun Microsystems, Inc   action text, URLs,
                        or any relevant info
Speaker’s Qualifications
●   Doris Chen
    –   Technology Evangelist at Sun Microsystems
    –   Develops and delivers Code Camps for
        J2EE, Java performance tuning, J2ME and web
        services technologies for Sun Microsystems
    –   Speaks around the world concerning
        Sun™ technologies
Presentation Agenda
●   JSP™/Servlets Overview
●   Frameworks
    •   Struts
    •   JavaServer™ Faces
    •   Sun™ ONE Application Framework (JATO)
●   Summary and Resources
How It Fits Together

       JSF                                      S1AF
                          JSTL
       Struts
                             JSP™
                java bean, expression
                lang.,custom tag lib

                         Servlet
        session tracking, filtering, listener
Web Foundation: JSP™/Servlets

●   Java Servlet technology since ’96, JSP 1.0
    specification in June ’99
●   Servlets and JSP technologies:
    •   JSP 1.2 and Java Servlet 2.3 technologies in the J2EE
        1.3 platform (now)
    •   JSP 2.0 and Java Servlet 2.4 technologies in the J2EE
        1.4 platform (proposed final draft)
Java Servlet Technology
●   Foundation for many technologies
    •   The JAX-RPC API
    •   Java portlet technology
    •   The JAXM API
    •   Struts, JavaServer Faces™, Sun™ ONE application
        framework
●   Well understood by industry
The JavaServer Pages™
    (JSP™) Specification
●   JavaServer Pages technology: Building
    Block
●   Mature spec
●   Widely Used
●   Many uses of Tag Libraries
●   Very good community, look for the
    JSP 2.0 release
JSP Architecture
                             Servlet Engine
 Client Request                 JSP
                             Translator


                  Redirect     JSP                 Create
Response          Load JSP   Servlet               Servlet


                                                 Load Servlet


                             JSP       Servlet
Frameworks                     Struts

Sun™ ONE Application
Framework              JS L
                         T         SA
                                    1F
                                    WAF

                           JavaServer Faces™
                                (events) Server
                       Client Request      UI


                               Response
                                 (markup)
Presentation Agenda
●   JSP™/Servlets Overview
●   Frameworks
    •   Struts
    •   JavaServer™ Faces
    •   Sun™ ONE Application Framework (JATO)
●   Summary and Resources
Jakarta Struts
●   Struts is an open source framework developed
    by the Apache Jakarta project
    http://jakarta.apache.org/struts/
     –   Struts 1.02 is available and Struts 1.1 is in beta
●   Struts allows:
     –   JSP/Servlet developers to fashion their web applications
         using the MVC design pattern
     –   Configure a lot of the default framework objects through
         xml configuration files
     –   Run Servlet2.2/JSP1.1 container and above
Model-View-Control (model 2)
                                                        MVC Design Pattern

              1
            Request
                           (Controller)
                           Servlet
  BROWSER




                                     In
                       Redirect 3


                                       st
                                                 2


                                         an
                                           tia
                                           te
              5           (View)                 (Model)
                                                 Java Bean
            Response      JSP             4



                           Servlet Container                     (EIS)
Struts: MVC Pattern Implemented

                                 Controller
                                                                   Model
                       Action          Action
                                       Mapping            Action
                       Servlet
           Request                      (xml)


 Client

                                                            uses
          Response

                                      Action     Action
                     JSP View
                                     Forward     Form          Model Data
  View
Struts Components and
    Feature
●   The View - a JSP or HTML page
●   The Model - a Java object ( called a
    ActionForm)
●   Central controller – ActionServlet
    •   URI to ActionMapping(Action class) located in struts-
        config.xml file
    •   Action classes
          • Adaptors between business layer and web tier


●   Validation, Internationalization, Custom
    tags for creating HTML, presentation logic,
    and templating
Model
●   Model classes should be coded independent
    of the Struts framework
    –       Maximum code reusability by other applications
●   Struts provides default Model components,
    most important one ActionForm
        •   Create model class by extending the Struts
            ActionForm class
●   Struts provides a org.apache.struts.util.PropertyUtils
    has a static method called copyProperties()
    –       To copy all form properties to your original model
            object when your controller receives a form
Controller
●   The controller is the switch board of MVC
●   Directs the user to the appropriate views by
    providing the view with the correct model
●   The task of directing users to appropriate views
    is called “mapping”
●   Struts framework provides a base object called
    org.apache.struts.action.ActionServlet
Controller (Cont.)
Http://myhost/authorize.do


Server configured to pass *.do extensions to
org.apache.struts.action.ActionServlet via a web.xml configuration file


ActionServlet object inspects the URI and tries to match it
against an ActionMapping located in the struts-config.xml file

Instance of appropriate Action class is found and it’s perform() is called


Action object handles the request and returns control to a view
based where the user is within the flow of the application
struts-config.xml: ActionMapping
<action-mappings>
       <action     path="/logon"
              type="org.apache.struts.example.LogonAction"
              name="logonForm"
              scope="request"
              input="/logon.jsp">
       </action>
       <forward    name="success” path="/msgBoard.jsp"/>
</action-mappings>
View
●   ActionForward object tells JSP page to dispatch
    to
●   The view in Struts is represented by JSP
●   JSP can use ActionForm bean to get output
    Model data to display
●   Struts contains a series of tag libraries
    –   Facilitates communication between HTML designers
        and developers
    –   Facilitates dynamic Web content
View: Example
1    <%@ page language="java" %>
2    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
3    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
4    <html:html locale="true">
5    <head>
6    <title><bean:message key="logon.title"/></title>
7    <html:base/>
8    </head> ...
9    <html:errors/>
10    ...
11    <html:form action="/logon.do" focus="username">
12    <table border="0" width="100%"> ...
13    <html:submit property="submit" value="Submit"/>
14     ...
15    </html:form>
16    ...
17    </html:html>
Struts Example
        Page 1                      Jsp 1        Jsp 2      Jsp 3


                 Web Browser


Web Server
                                                                                       Form      Request/session   View
                                            Jsp Engine                                 Bean      Form
                                                                                         1       Bean    Other
                                                                                                                   Layer
                                                                                                   2     Bean
                                                                                                           1


                          Controller
    Struts-
    config.
     xml
                     Mappings

                 •    path                  Action1           Action2               Action3             Action4
                 •    action                 .java             .java                 .java               .java
                 •    [form bean]
                 •    [forwards]
                                                                                                                   Business
                                                 Business                Business                 Business
                                                  Bean 1                  Bean 2                   Bean 3           Logic
                                                                                                                    Layer
                                    CoreSession             CoreSession                       Socket
                                                                                                                   Data
                                                                    MarkVision Server                              Layer
Presentation Agenda
●   JSP™/Servlets Overview
●   Frameworks
    •   Struts
    •   JavaServer™ Faces
    •   Sun™ ONE Application Framework (JATO)
●   Summary and Resources
JavaServer Faces Design Goals
●   Tool Friendly
●   Client device neutral
●   Usable with JavaServer Pages (JSP)
●   Usable without JSP
●   Useful in today's lowest common
    denominator browsers
●   Scalable
JavaServer Faces Requirements
●   Extensible UI component model
●   Flexible rendering model
●   Comprehensive event model
●   Powerful Validation framework
●   Flexible error handling
●   Basic page navigation
●   Internationalization and Accessibility
How the JSF Specification Fits
In
         JSF App
                        JSF App
        JSF Tags

       JSP (1.2)       JSF API

            Servlets (2.3)
JSF Architecture
                        Server

             Request     UI
   Client    (Events)


            Response


            (Markup)
JSF Architecture
                           Server
                           JSF Page
             HTML
   Desktop
                                 HM
                                  TL
   Browser                     R d it
                                en erK


                   Front                   App
                   ctrl      JSF Page    Backend


                                 WL
                                  M
                               R d it
                                en erK
   Phone
             WML
JSF Specification: Customers
        Application            Extensions


                                     Tools
      Page                         Developer
     Author
                  Component
                   Developer           JSF
    Application                   Implementor/
     Developer                      Extender
Key JSF Concepts
●   UIComponent – JavaBean like classes
    ─ Render-independent characteristics
    ─ Base class with standard behaviors
●   Standard UIComponent Subclasses:
    ─ UICommand, UIForm, UIGraphic, UIInput, UIOutput, UIPanel,
      UISelectBoolean, UISelectMany, UISelectOne
●   FacesEvent – Base class for request and
    application events
●   Validator – Base class for standard and
    application defined validators
Key JSF Concepts
●   Converter – Plug-in for String-Object
    conversion
●   FacesContext – Per-Request State:
    ─ Servlet request, response, session
    ─ JSF request, response trees
    ─ Model reference expression evaluators
       • Syntax similar to the expression language of the JSP
         Standard Tag Library (JSTL) 1.0
       • Primary interface between components and the data
         provided by (or to) the application
Key JSF Concepts

●   Renderer – Converts components to and
    from a specific markup language
    ─ Supports render-dependent attributes on
      components
    ─ May support more than one component type
●   RenderKit – Library of Renderers
    ─ Extensible at runtime
    ─ Basic HTML RenderKit is part of the specification
JSF Example
1    <%@ page language="java" %>
2    <%@ taglib uri="http:://java.sun.com/j2ee/html_basic" prefix="faces" %>
3
4    <jsp:usebean id="UserNumberBean” class=”NumberBean” scope=session>
5    <faces:usefaces>
6     <faces:form id="helloForm" forname="helloForm">
7     <faces:textentry_input id="username" modelReference
8     ="UserNameBean.userName">
9
10     <faces:command_button id="submitButton" label="submit">
11    </faces:form>
12    </faces:usefaces>
13    ...
14    </html:html>
Component Tree


                        HelloForm




 Input                                             Form
 text        UserName               Submit         event
    Stored                                   Queued
Steps in Development Process
●   Author the pages using the UI component
    tags
    •   useBean tag
    •   faces tags:
         •   faces:form, faces:textentry_input, faces:command_button
●   Develop the model objects, which will hold
    the data
●   Develop navigation handlers
    •   Define the navigation for the application by
        implementing ApplicationHandler class
Current Development Status
●   Warning – everything above is subject to
    change!
●   Under development in JSR-127
    ─ Introduced at JavaOne US 2001
●   Large expert group
    ─ Framework developers, Tools providers, ISVs
●   Completed Community Draft status (07/2002)
●   Working towards Public Draft release of
    specification
Current Development Status
●   Early Access of Reference Implementation
    is also available
●   Early Access (pre-Public Draft) Specification
    available:
    •   http://java.sun.com/j2ee/javaserverfaces/
●   JSF Public Forum:
    •   http://forum.java.sun.com/forum.jsp?forum=427
●   JSF Comments: jsr-127-
    comments@sun.com
●   Intranet Site:
    http://wspack.sfbay.sun.com/jsf
If You Only Remember One
Thing…
●   JavaServer Faces is destined to become the
    standard mechanism for creating user
    interface components for J2EE based web
    applications.
Presentation Agenda
●   JSP™/Servlets Overview
●   Frameworks
    •   Struts
    •   Sun™ ONE Application Framework (JATO)
    •   JavaServer™ Faces
●   Summary and Resources
Sun™ ONE Application
Framework (JATO) Overview
●   A J2EE application framework
    •   Primarily focused on web tier
    •   Leverage Sun Java Center J2EE Patterns
●   Provide a robust, scalable application
    foundation
    •   Application composition via reusable components
    •   Full-featured event model and high-level tag library
●   SOAP & Web Services support / integration
●   Leveraged through Sun ONE Studio Wizard-
    based visual interfaces
Where can the Sun ONE
Application Framework be used?
●   Enterprises or ISV's building large
    enterprise web applications
●   Large development team (10+) focused on
    web applications
●   Few really know Java APIs at the web tier
    or enterprise tier
Sun ONE Application Framework
(JATO) Platform Stack
S1AF and Your Application
J2EE Design Pattern
●   Leverage Sun Java Center J2EE Patterns
    •   Best practice design patterns for J2EE
        development
    •   Fine grained patterns
         •   Can be combined into a complete MVC

●   Use Model View Controller pattern
    (MVC)
J2EE patterns used in S1AF

●   Business delegate
●   View helper
●   Composite view
●   Service to worker
●   Front controller
Sun ONE Application Framework
Models
 ●   Implements Business Delegate pattern
     –   Reduce coupling between presentation tier clients and business
         services
     –   Hides the underlying implementation details of business service
         (e.g. JDBC details)
 ●   Provides developers a common interface for using any
     Enterprise resource
     –   Web Service resources
     –   Database resources
     –   UIF (Enterprise Connectors) resources
     –   J2EE Connector Architecture resources
     –   AND 3rd party created
Views
●   A union of JSP tags with S1AF view objects
    –   S1AF JSPs use S1AF tags and othe 3rd party tags
    –   S1AF views simply refer to model data
●   Implements J2EE view helper pattern
    –   S1AF views allows JSPs to remain Java-free
    –   Presentation logic is placed in View class
    –   More than one JSP can use a View Helper
        •   Allows for variable content rendering

●   Implements J2EE Composite View Pattern
    –   S1AF view may be arbitrarily nested
JSP/View/Model Relationships
Controller
●   Consistes of two patterns
    –   Front controller
    –   Service to workers
●   Implements front controller pattern
    –   All requests pass through front controller
    –   Module servlet serves as front controller
    –   Single point of entry allows for centralization
        of certain types of logic
Controller (Cont.)

●   Implements ServiceToWorker pattern
    –   Single service dispatches to request specific
        controllers(workers)
        •   All requests pass through the FrontController
        •   Controller logic can be partitioned into more fine
            grained units for scalability and logical partitioning
    –   S1AF module servlet dispatches request to
        the appropriate worker (controller)
        •   S1AF controller can be a Command interface
        •   Developers will implement the command interface
Tool & Wizard Friendly
View Components
●   “ Out of the box” Page components are available such
    as Button, Check Box, Combo Box
●   3rd party (SI’s) components can be dynamically added
    to the product
Component Story
Component Story
Component Story
Component Story
Component Story
Presentation Agenda
●   JSP™/Servlets Overview
●   Frameworks
    •   Struts
    •   JavaServer™ Faces
    •   Sun™ ONE Application Framework (JATO)
●   Summary and Resources
JSF, Struts and S1AF
●   Focus is a bit different
    –   Struts: encapsulates user-interface more at form or page level
    –   JSF: UI components, component model for user-interface, Tools
        focus
    –   S1AF: extends MVC and J2EE design pattern and comes with an
        extendable but ready-to use base implementation, visual builder
        tool
●   Some overlap
    –   Use the parts that are helpful, ignore the parts that are not
    –   Pick solution best suited to expertise/task
    –   JSF/Struts integration
    http://jakarta.apache.org/builds/jakarta-struts/nightly/struts-
      faces/
JSF, S1AF, and Struts
●   All three communities are represented on
    JSR-127 expert group
    –   The lead developer of Struts, Craig McClanahan, now
        works for Sun and is a member of JSF expert group
    –   S1AF Architect is already participating in expert group
        meeting
    –   Long term strategy:
         ●   S1AF and struts will co-exists/merge with S1af evolving to
             use struts controller technology and JSF components
         ●   Goal is to provide a single web-based framework also
             monetizes struts technology
Where to look further
●   JSF
    http://java.sun.com/products/j2ee/javaserverfa
●   Struts http://jakarta.apache.org/struts
●   A good place to start is the S1AF-Tips group:
    http://groups.yahoo.com/group/iPlanet-JATO-
    Tips/
●   FAQ of the larger community forum at:
    http://groups.yahoo.com/group/iPlanet -JATO/
●   The Whitepaper: http://ias.red.iPlanet.com/jato
●   You can get more information at:
    http://developer.iPlanet.com/tech/appserver/fr
    amework/index.jsp
JavaServer Pages™ /Servlets
and Web Application Frameworks

Doris Chen, Ph.D
doris.chen@sun.com

More Related Content

What's hot

Struts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web ApplicationsStruts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web Applications
elliando dias
 
Struts Introduction Course
Struts Introduction CourseStruts Introduction Course
Struts Introduction Course
guest764934
 
Sun JSF Presentation
Sun JSF PresentationSun JSF Presentation
Sun JSF Presentation
Gaurav Dighe
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
Tuna Tore
 
Java Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC FrameworkJava Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC Framework
Guo Albert
 

What's hot (20)

Struts course material
Struts course materialStruts course material
Struts course material
 
Java server faces
Java server facesJava server faces
Java server faces
 
Introduction to JSF
Introduction toJSFIntroduction toJSF
Introduction to JSF
 
Jsf intro
Jsf introJsf intro
Jsf intro
 
Struts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web ApplicationsStruts An Open-source Architecture for Web Applications
Struts An Open-source Architecture for Web Applications
 
A Complete Tour of JSF 2
A Complete Tour of JSF 2A Complete Tour of JSF 2
A Complete Tour of JSF 2
 
Struts Introduction Course
Struts Introduction CourseStruts Introduction Course
Struts Introduction Course
 
Sun JSF Presentation
Sun JSF PresentationSun JSF Presentation
Sun JSF Presentation
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
 
Jsf2.0 -4
Jsf2.0 -4Jsf2.0 -4
Jsf2.0 -4
 
Modular applications with montage components
Modular applications with montage componentsModular applications with montage components
Modular applications with montage components
 
JSF Component Behaviors
JSF Component BehaviorsJSF Component Behaviors
JSF Component Behaviors
 
MVC on the server and on the client
MVC on the server and on the clientMVC on the server and on the client
MVC on the server and on the client
 
Spring Portlet MVC
Spring Portlet MVCSpring Portlet MVC
Spring Portlet MVC
 
Mike Taulty MIX10 Silverlight 4 Patterns Frameworks
Mike Taulty MIX10 Silverlight 4 Patterns FrameworksMike Taulty MIX10 Silverlight 4 Patterns Frameworks
Mike Taulty MIX10 Silverlight 4 Patterns Frameworks
 
Jsf
JsfJsf
Jsf
 
Java EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVCJava EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVC
 
Java Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC FrameworkJava Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC Framework
 
Java Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsJava Server Faces (JSF) - Basics
Java Server Faces (JSF) - Basics
 
TY.BSc.IT Java QB U5&6
TY.BSc.IT Java QB U5&6TY.BSc.IT Java QB U5&6
TY.BSc.IT Java QB U5&6
 

Viewers also liked

Viewers also liked (10)

Spring mvc
Spring mvcSpring mvc
Spring mvc
 
ETOM Enterprise Framework Management
ETOM Enterprise Framework ManagementETOM Enterprise Framework Management
ETOM Enterprise Framework Management
 
Luận văn tìm hiểu Spring
Luận văn tìm hiểu SpringLuận văn tìm hiểu Spring
Luận văn tìm hiểu Spring
 
E tom awareness session for quick overview and deployment
E tom awareness session for quick overview and deploymentE tom awareness session for quick overview and deployment
E tom awareness session for quick overview and deployment
 
eTOM - Foundation
eTOM - FoundationeTOM - Foundation
eTOM - Foundation
 
ASP, ASP.NET, JSP, COM/DCOM
ASP, ASP.NET, JSP, COM/DCOMASP, ASP.NET, JSP, COM/DCOM
ASP, ASP.NET, JSP, COM/DCOM
 
eTOM and ITIL engagements
eTOM and ITIL engagementseTOM and ITIL engagements
eTOM and ITIL engagements
 
Lecture 4: JavaServer Pages (JSP) & Expression Language (EL)
Lecture 4:  JavaServer Pages (JSP) & Expression Language (EL)Lecture 4:  JavaServer Pages (JSP) & Expression Language (EL)
Lecture 4: JavaServer Pages (JSP) & Expression Language (EL)
 
Applying eTOM (enhanced Telecom Operations Map) Framework to Non-Telecommunic...
Applying eTOM (enhanced Telecom Operations Map) Framework to Non-Telecommunic...Applying eTOM (enhanced Telecom Operations Map) Framework to Non-Telecommunic...
Applying eTOM (enhanced Telecom Operations Map) Framework to Non-Telecommunic...
 
Telecommunication Business Process - eTOM Flows
Telecommunication Business Process - eTOM FlowsTelecommunication Business Process - eTOM Flows
Telecommunication Business Process - eTOM Flows
 

Similar to Jsf Framework

Java EE 6 - Deep Dive - Indic Threads, Pune - 2010
Java EE 6 - Deep Dive - Indic Threads, Pune - 2010Java EE 6 - Deep Dive - Indic Threads, Pune - 2010
Java EE 6 - Deep Dive - Indic Threads, Pune - 2010
Jagadish Prasath
 
Java EE 6 = Less Code + More Power (Tutorial) [5th IndicThreads Conference O...
Java EE 6 = Less Code + More Power (Tutorial)  [5th IndicThreads Conference O...Java EE 6 = Less Code + More Power (Tutorial)  [5th IndicThreads Conference O...
Java EE 6 = Less Code + More Power (Tutorial) [5th IndicThreads Conference O...
IndicThreads
 

Similar to Jsf Framework (20)

Jsf2 overview
Jsf2 overviewJsf2 overview
Jsf2 overview
 
Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
 
Struts Basics
Struts BasicsStruts Basics
Struts Basics
 
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionJava EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
 
Java EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerJava EE 6 = Less Code + More Power
Java EE 6 = Less Code + More Power
 
Development of web apps based on JSF (TU Vienna)
Development of web apps based on JSF (TU Vienna)Development of web apps based on JSF (TU Vienna)
Development of web apps based on JSF (TU Vienna)
 
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUGJava EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
 
J2EE jsp_01
J2EE jsp_01J2EE jsp_01
J2EE jsp_01
 
14 mvc
14 mvc14 mvc
14 mvc
 
PUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBoot
 
Struts ppt 1
Struts ppt 1Struts ppt 1
Struts ppt 1
 
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3 Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
 
Java EE 6 - Deep Dive - Indic Threads, Pune - 2010
Java EE 6 - Deep Dive - Indic Threads, Pune - 2010Java EE 6 - Deep Dive - Indic Threads, Pune - 2010
Java EE 6 - Deep Dive - Indic Threads, Pune - 2010
 
Java EE 6 = Less Code + More Power (Tutorial) [5th IndicThreads Conference O...
Java EE 6 = Less Code + More Power (Tutorial)  [5th IndicThreads Conference O...Java EE 6 = Less Code + More Power (Tutorial)  [5th IndicThreads Conference O...
Java EE 6 = Less Code + More Power (Tutorial) [5th IndicThreads Conference O...
 
Introducing spring
Introducing springIntroducing spring
Introducing spring
 
Jsp (java server page)
Jsp (java server page)Jsp (java server page)
Jsp (java server page)
 
Java EE 6 : Paving The Path For The Future
Java EE 6 : Paving The Path For The FutureJava EE 6 : Paving The Path For The Future
Java EE 6 : Paving The Path For The Future
 
Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 

Jsf Framework

  • 1. JavaServer Pages™ /Servlets and Web Application Frameworks Doris Chen, Ph.D Staff Engineer This box provides space for call to Sun Microsystems, Inc action text, URLs, or any relevant info
  • 2. Speaker’s Qualifications ● Doris Chen – Technology Evangelist at Sun Microsystems – Develops and delivers Code Camps for J2EE, Java performance tuning, J2ME and web services technologies for Sun Microsystems – Speaks around the world concerning Sun™ technologies
  • 3. Presentation Agenda ● JSP™/Servlets Overview ● Frameworks • Struts • JavaServer™ Faces • Sun™ ONE Application Framework (JATO) ● Summary and Resources
  • 4. How It Fits Together JSF S1AF JSTL Struts JSP™ java bean, expression lang.,custom tag lib Servlet session tracking, filtering, listener
  • 5. Web Foundation: JSP™/Servlets ● Java Servlet technology since ’96, JSP 1.0 specification in June ’99 ● Servlets and JSP technologies: • JSP 1.2 and Java Servlet 2.3 technologies in the J2EE 1.3 platform (now) • JSP 2.0 and Java Servlet 2.4 technologies in the J2EE 1.4 platform (proposed final draft)
  • 6. Java Servlet Technology ● Foundation for many technologies • The JAX-RPC API • Java portlet technology • The JAXM API • Struts, JavaServer Faces™, Sun™ ONE application framework ● Well understood by industry
  • 7. The JavaServer Pages™ (JSP™) Specification ● JavaServer Pages technology: Building Block ● Mature spec ● Widely Used ● Many uses of Tag Libraries ● Very good community, look for the JSP 2.0 release
  • 8. JSP Architecture Servlet Engine Client Request JSP Translator Redirect JSP Create Response Load JSP Servlet Servlet Load Servlet JSP Servlet
  • 9. Frameworks Struts Sun™ ONE Application Framework JS L T SA 1F WAF JavaServer Faces™ (events) Server Client Request UI Response (markup)
  • 10. Presentation Agenda ● JSP™/Servlets Overview ● Frameworks • Struts • JavaServer™ Faces • Sun™ ONE Application Framework (JATO) ● Summary and Resources
  • 11. Jakarta Struts ● Struts is an open source framework developed by the Apache Jakarta project http://jakarta.apache.org/struts/ – Struts 1.02 is available and Struts 1.1 is in beta ● Struts allows: – JSP/Servlet developers to fashion their web applications using the MVC design pattern – Configure a lot of the default framework objects through xml configuration files – Run Servlet2.2/JSP1.1 container and above
  • 12. Model-View-Control (model 2) MVC Design Pattern 1 Request (Controller) Servlet BROWSER In Redirect 3 st 2 an tia te 5 (View) (Model) Java Bean Response JSP 4 Servlet Container (EIS)
  • 13. Struts: MVC Pattern Implemented Controller Model Action Action Mapping Action Servlet Request (xml) Client uses Response Action Action JSP View Forward Form Model Data View
  • 14. Struts Components and Feature ● The View - a JSP or HTML page ● The Model - a Java object ( called a ActionForm) ● Central controller – ActionServlet • URI to ActionMapping(Action class) located in struts- config.xml file • Action classes • Adaptors between business layer and web tier ● Validation, Internationalization, Custom tags for creating HTML, presentation logic, and templating
  • 15. Model ● Model classes should be coded independent of the Struts framework – Maximum code reusability by other applications ● Struts provides default Model components, most important one ActionForm • Create model class by extending the Struts ActionForm class ● Struts provides a org.apache.struts.util.PropertyUtils has a static method called copyProperties() – To copy all form properties to your original model object when your controller receives a form
  • 16. Controller ● The controller is the switch board of MVC ● Directs the user to the appropriate views by providing the view with the correct model ● The task of directing users to appropriate views is called “mapping” ● Struts framework provides a base object called org.apache.struts.action.ActionServlet
  • 17. Controller (Cont.) Http://myhost/authorize.do Server configured to pass *.do extensions to org.apache.struts.action.ActionServlet via a web.xml configuration file ActionServlet object inspects the URI and tries to match it against an ActionMapping located in the struts-config.xml file Instance of appropriate Action class is found and it’s perform() is called Action object handles the request and returns control to a view based where the user is within the flow of the application
  • 18. struts-config.xml: ActionMapping <action-mappings> <action path="/logon" type="org.apache.struts.example.LogonAction" name="logonForm" scope="request" input="/logon.jsp"> </action> <forward name="success” path="/msgBoard.jsp"/> </action-mappings>
  • 19. View ● ActionForward object tells JSP page to dispatch to ● The view in Struts is represented by JSP ● JSP can use ActionForm bean to get output Model data to display ● Struts contains a series of tag libraries – Facilitates communication between HTML designers and developers – Facilitates dynamic Web content
  • 20. View: Example 1 <%@ page language="java" %> 2 <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> 3 <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> 4 <html:html locale="true"> 5 <head> 6 <title><bean:message key="logon.title"/></title> 7 <html:base/> 8 </head> ... 9 <html:errors/> 10 ... 11 <html:form action="/logon.do" focus="username"> 12 <table border="0" width="100%"> ... 13 <html:submit property="submit" value="Submit"/> 14 ... 15 </html:form> 16 ... 17 </html:html>
  • 21. Struts Example Page 1 Jsp 1 Jsp 2 Jsp 3 Web Browser Web Server Form Request/session View Jsp Engine Bean Form 1 Bean Other Layer 2 Bean 1 Controller Struts- config. xml Mappings • path Action1 Action2 Action3 Action4 • action .java .java .java .java • [form bean] • [forwards] Business Business Business Business Bean 1 Bean 2 Bean 3 Logic Layer CoreSession CoreSession Socket Data MarkVision Server Layer
  • 22. Presentation Agenda ● JSP™/Servlets Overview ● Frameworks • Struts • JavaServer™ Faces • Sun™ ONE Application Framework (JATO) ● Summary and Resources
  • 23. JavaServer Faces Design Goals ● Tool Friendly ● Client device neutral ● Usable with JavaServer Pages (JSP) ● Usable without JSP ● Useful in today's lowest common denominator browsers ● Scalable
  • 24. JavaServer Faces Requirements ● Extensible UI component model ● Flexible rendering model ● Comprehensive event model ● Powerful Validation framework ● Flexible error handling ● Basic page navigation ● Internationalization and Accessibility
  • 25. How the JSF Specification Fits In JSF App JSF App JSF Tags JSP (1.2) JSF API Servlets (2.3)
  • 26. JSF Architecture Server Request UI Client (Events) Response (Markup)
  • 27. JSF Architecture Server JSF Page HTML Desktop HM TL Browser R d it en erK Front App ctrl JSF Page Backend WL M R d it en erK Phone WML
  • 28. JSF Specification: Customers Application Extensions Tools Page Developer Author Component Developer JSF Application Implementor/ Developer Extender
  • 29. Key JSF Concepts ● UIComponent – JavaBean like classes ─ Render-independent characteristics ─ Base class with standard behaviors ● Standard UIComponent Subclasses: ─ UICommand, UIForm, UIGraphic, UIInput, UIOutput, UIPanel, UISelectBoolean, UISelectMany, UISelectOne ● FacesEvent – Base class for request and application events ● Validator – Base class for standard and application defined validators
  • 30. Key JSF Concepts ● Converter – Plug-in for String-Object conversion ● FacesContext – Per-Request State: ─ Servlet request, response, session ─ JSF request, response trees ─ Model reference expression evaluators • Syntax similar to the expression language of the JSP Standard Tag Library (JSTL) 1.0 • Primary interface between components and the data provided by (or to) the application
  • 31. Key JSF Concepts ● Renderer – Converts components to and from a specific markup language ─ Supports render-dependent attributes on components ─ May support more than one component type ● RenderKit – Library of Renderers ─ Extensible at runtime ─ Basic HTML RenderKit is part of the specification
  • 32. JSF Example 1 <%@ page language="java" %> 2 <%@ taglib uri="http:://java.sun.com/j2ee/html_basic" prefix="faces" %> 3 4 <jsp:usebean id="UserNumberBean” class=”NumberBean” scope=session> 5 <faces:usefaces> 6 <faces:form id="helloForm" forname="helloForm"> 7 <faces:textentry_input id="username" modelReference 8 ="UserNameBean.userName"> 9 10 <faces:command_button id="submitButton" label="submit"> 11 </faces:form> 12 </faces:usefaces> 13 ... 14 </html:html>
  • 33. Component Tree HelloForm Input Form text UserName Submit event Stored Queued
  • 34. Steps in Development Process ● Author the pages using the UI component tags • useBean tag • faces tags: • faces:form, faces:textentry_input, faces:command_button ● Develop the model objects, which will hold the data ● Develop navigation handlers • Define the navigation for the application by implementing ApplicationHandler class
  • 35. Current Development Status ● Warning – everything above is subject to change! ● Under development in JSR-127 ─ Introduced at JavaOne US 2001 ● Large expert group ─ Framework developers, Tools providers, ISVs ● Completed Community Draft status (07/2002) ● Working towards Public Draft release of specification
  • 36. Current Development Status ● Early Access of Reference Implementation is also available ● Early Access (pre-Public Draft) Specification available: • http://java.sun.com/j2ee/javaserverfaces/ ● JSF Public Forum: • http://forum.java.sun.com/forum.jsp?forum=427 ● JSF Comments: jsr-127- comments@sun.com ● Intranet Site: http://wspack.sfbay.sun.com/jsf
  • 37. If You Only Remember One Thing… ● JavaServer Faces is destined to become the standard mechanism for creating user interface components for J2EE based web applications.
  • 38. Presentation Agenda ● JSP™/Servlets Overview ● Frameworks • Struts • Sun™ ONE Application Framework (JATO) • JavaServer™ Faces ● Summary and Resources
  • 39. Sun™ ONE Application Framework (JATO) Overview ● A J2EE application framework • Primarily focused on web tier • Leverage Sun Java Center J2EE Patterns ● Provide a robust, scalable application foundation • Application composition via reusable components • Full-featured event model and high-level tag library ● SOAP & Web Services support / integration ● Leveraged through Sun ONE Studio Wizard- based visual interfaces
  • 40. Where can the Sun ONE Application Framework be used? ● Enterprises or ISV's building large enterprise web applications ● Large development team (10+) focused on web applications ● Few really know Java APIs at the web tier or enterprise tier
  • 41. Sun ONE Application Framework (JATO) Platform Stack
  • 42. S1AF and Your Application
  • 43. J2EE Design Pattern ● Leverage Sun Java Center J2EE Patterns • Best practice design patterns for J2EE development • Fine grained patterns • Can be combined into a complete MVC ● Use Model View Controller pattern (MVC)
  • 44. J2EE patterns used in S1AF ● Business delegate ● View helper ● Composite view ● Service to worker ● Front controller
  • 45. Sun ONE Application Framework
  • 46. Models ● Implements Business Delegate pattern – Reduce coupling between presentation tier clients and business services – Hides the underlying implementation details of business service (e.g. JDBC details) ● Provides developers a common interface for using any Enterprise resource – Web Service resources – Database resources – UIF (Enterprise Connectors) resources – J2EE Connector Architecture resources – AND 3rd party created
  • 47. Views ● A union of JSP tags with S1AF view objects – S1AF JSPs use S1AF tags and othe 3rd party tags – S1AF views simply refer to model data ● Implements J2EE view helper pattern – S1AF views allows JSPs to remain Java-free – Presentation logic is placed in View class – More than one JSP can use a View Helper • Allows for variable content rendering ● Implements J2EE Composite View Pattern – S1AF view may be arbitrarily nested
  • 49. Controller ● Consistes of two patterns – Front controller – Service to workers ● Implements front controller pattern – All requests pass through front controller – Module servlet serves as front controller – Single point of entry allows for centralization of certain types of logic
  • 50. Controller (Cont.) ● Implements ServiceToWorker pattern – Single service dispatches to request specific controllers(workers) • All requests pass through the FrontController • Controller logic can be partitioned into more fine grained units for scalability and logical partitioning – S1AF module servlet dispatches request to the appropriate worker (controller) • S1AF controller can be a Command interface • Developers will implement the command interface
  • 51. Tool & Wizard Friendly
  • 52. View Components ● “ Out of the box” Page components are available such as Button, Check Box, Combo Box ● 3rd party (SI’s) components can be dynamically added to the product
  • 58. Presentation Agenda ● JSP™/Servlets Overview ● Frameworks • Struts • JavaServer™ Faces • Sun™ ONE Application Framework (JATO) ● Summary and Resources
  • 59. JSF, Struts and S1AF ● Focus is a bit different – Struts: encapsulates user-interface more at form or page level – JSF: UI components, component model for user-interface, Tools focus – S1AF: extends MVC and J2EE design pattern and comes with an extendable but ready-to use base implementation, visual builder tool ● Some overlap – Use the parts that are helpful, ignore the parts that are not – Pick solution best suited to expertise/task – JSF/Struts integration http://jakarta.apache.org/builds/jakarta-struts/nightly/struts- faces/
  • 60. JSF, S1AF, and Struts ● All three communities are represented on JSR-127 expert group – The lead developer of Struts, Craig McClanahan, now works for Sun and is a member of JSF expert group – S1AF Architect is already participating in expert group meeting – Long term strategy: ● S1AF and struts will co-exists/merge with S1af evolving to use struts controller technology and JSF components ● Goal is to provide a single web-based framework also monetizes struts technology
  • 61. Where to look further ● JSF http://java.sun.com/products/j2ee/javaserverfa ● Struts http://jakarta.apache.org/struts ● A good place to start is the S1AF-Tips group: http://groups.yahoo.com/group/iPlanet-JATO- Tips/ ● FAQ of the larger community forum at: http://groups.yahoo.com/group/iPlanet -JATO/ ● The Whitepaper: http://ias.red.iPlanet.com/jato ● You can get more information at: http://developer.iPlanet.com/tech/appserver/fr amework/index.jsp
  • 62. JavaServer Pages™ /Servlets and Web Application Frameworks Doris Chen, Ph.D doris.chen@sun.com