Java Web Programming [1/9] : Introduction to Web Application

IMC Institute
IMC InstituteCommittee of the Council um IMC Institute
Module 1: Introduction to
   Web Application


  Thanisa Krauwaisayawan
   Thanachart Numnonda
   www.imcinstitute.com
Objectives
   Evolution of Enterprise Application Frameworks
   Overview: Java EE
   Web application, components and Web container
   Web application development and deployment steps
   Building Simple Web Applications using Eclipse and Tomcat
   Web Application Archive (*.WAR file)
       *.WAR directory structure
       WEB-INF subdirectory
   Deploying WAR file to Server



                                                                2
Evolution of Enterprise Application
            Framework
   Single tier
   Two tier
   Three tier
       –    RPC based
       –    Remote object based
   Three tier (HTML browser and Web server)
   Proprietary and standard application server

                                                  3
Single Tier (Mainframe-based)




   Dumb terminals are directly connected to
    mainframe
   Centralized model (as opposed distributed model)
   Presentation, business logic, and data access are
    intertwined in one monolithic mainframe
    application
                                                        4
Two-Tier
                        SQL
                        request
                                      Database
                        SQL
                        response




 Fat   clients talking to back end database
      SQL queries sent, raw data returned
   Presentation,Business logic and Data Model
    processing logic in client application

                                                 5
Three-Tier (RPC based)

                                           SQL
                   RPC request             request
                                                          Database
                   RPC response            SQL
                                           response

   Thinner client: business & data model separated from
    presentation
      Business logic and data access logic reside in middle tier
       server while client handles presentation
   Middle tier server is now required to handle system services
      Concurrency control, threading, transaction, security,
       persistence, multiplexing, performance, etc.
                                                                     6
Three-Tier (Remote Object based)
                                            SQL
                   Object request           request
                                                       Database
                   Object                  SQL
                   response                response



   Business logic and data model captured in objects
    – Business logic and data model are now described in
      “abstraction” (interface language)
   Object models used: CORBA, RMI, DCOM
       Interface language in CORBA is IDL
       Interface language in RMI is Java interface
                                                                  7
Three-Tier (Web Server)

                               WEB      SQL
               HTML request             request
                               Server
                                                   Database
               HTML response            SQL
                                        response




   Browser handles presentation logic
   Browser talks Web server via HTTP protocol
   Business logic and data model are handled by
    “dynamic contents generation” technologies (CGI,
    Servlet/JSP, ASP)
                                                              8
Proprietary and Standard Solution
   Comlexity at the middle tier server still remains
   Duplicate system services still need to be provided for
    the majority of enterprise applications
       –   Concurrency control, Transactions
       –   Load-balancing, Security
       –   Resource management, Connection pooling
   How to solve this problem?
       –   Commonly shared container that handles the
           above system services
       –   Proprietary versus standard based
JavaTM 2 Platform
                          Java Platform Micro Edition
                                   (Java ME)



 Optional
 Packages

               Optional
               Packages



                             Personal       Personal
  Java         Java         Basis Profile    Profile
Enterprise   Standard
 Edition      Edition         Foundation Profile       MIDP
(Java EE)    (Java SE)
                                        CDC                    Java
                                                       CLDC    Card

                      JVM                              KVM    Card VM

                                                                        10
Overview: Java EE

 Java EE is Java SE plus a large number of
  serverside APIs, containers and tools.
 Web Tier to Go With Java EE 6
       –   Servlet 3.0 (JSR 315)
       –   JavaServer Pages 2.2 (JSR 245)
   Many other subsystems standardized under a
    single platform
          EJB, JPA, JMS, JavaMail API, …
                                                 11
Java EE is End-to-End Solution
         Firewall
                         Java EE
                        Application
               Client     Server

                                                          Enterprise
                                        Enterprise       Information
                                       JavaBeans™
               Client                                   Systems (EIS):
Client                                                    Relational
                                                          Database,
                          Web           Enterprise         Legacy
Client                   Server         JavaBeans        Applications,
                         JSP,
                        Servlets                        ERP Systems
Client
             HTML/XML
                                      Other Services:
                                        JNDI, JMS,       Enterprise
         Client         Middle          JavaMail™       Information
          Tier           Tier                                Tier
                                                                         12
Web Server




             13
Web Components & Container
Applet Container                                  Web Container                                          EJB Container

    Applet                   HTTP/          JSP               Servlet
                             HTTPS                                                    RMI                       EJB

        J2SE




                                                                    RMI/IIOP
                                                                                                                JavaMail




                                                                                                                           RMI/IIOP
                                                         JavaMail




                                                                                                                                      JDBC
                                                                               JDBC
                                            JMS
                                     JNDI



                                                   JTA




                                                                                            JNDI

                                                                                                   JMS

                                                                                                          JTA
    App Client
    Container                                              JAF                                                   JAF
      App      HTTP/
     Client    HTTPS
                                                     J2SE

                                                     RMI
               RMI/IIOP

                          JDBC
 JNDI
        JMS




         J2SE                                                                                             J2SE




                                                                                                         Database
                                                                                                                                             14
Web Components & Container
   Web components are in the form of either Servlet or
    JSP (along with JavaBean's and custom tags)
   Web components run in a Web container
        Tomcat is a popular web containers
        All Java EE compliant app servers (GlassFish App Server)
         provide web containers
   Web container provides system services to Web
    components
        Request dispatching, security, and life cycle management
Components/Containers Handle
    Components            Containers
      Handle               Handle
   Presentation        Concurrency
   Business Logic      Security
                        Availability
                        Scalability
                        Persistence
                        Transaction
                        Life-cycle
                         management
                        Management
                                        16
Some definitions of the Web
            Development Process
   Web Page:
       simple text file consisting of text and HTML tags
   Web Browser:
       connects to a Web Server, sends a request for a page and
        receives and displays the result
       interprets HTML tags to display the page exactly the way
        the designer wanted it to be
   Web Server:
       software which can respond to a Web browser’s request for
        a page and then send that page to the browser

                                                                    17
Web Application & Components
   Web Application is a deployable package
       Web components (Servlets and JSP's)
       Static resource files such as images
       Helper classes
       Libraries
       Deployment descriptor (web.xml file)

   Web Application can be represented as
       A hierarchy of directories and files (unpacked form) or
       *.WAR file reflecting the same hierarchy (packed form)
                                                                  18
1. Create Development Tree Structure
 KeepWeb application source separate from
 compiled files
    –    facilitate iterative development
 Root   directory
    –    src: Java source of servlets and JavaBeans
         components
    –    WebContent: JSP pages and HTML pages,
         images

                                                      19
2. Create any static resources
 HTML    pages
     welcomePage.html
 Imagefiles that are used by HTML pages or
 JSP pages
     Example: dukeWaving.png




                                              20
3. Create deployment descriptor
           (web.xml)
 Deployment descriptor contains
 deployment time runtime instructions to the
 Web container
     URL that the client uses to access the web
      component
 Every web application has to have it
 For Servlet 3.0, web.xml is optional.
                                                   21
4. Build the Web application
   Build process is made of
      create build directory (if it is not present) and its
       subdirectories
      compile Java code into build/classes directory




                                                               22
Example: Hello Tree Structure
    Hello
    – build/classes
          •   ResultServlet.class
    –   src
          •   ResultServlet.java
    –   WebContent
          •   WEB-INF
          •   META-INF
          •   welcomePage.html
          •   dukeWaving.png
                                    23
5. Deploy Web application
   Deploy the application over deployment platform
    such as Sun Java System App Server or Tomcat




                                                      24
6. Perform Client Access to Web
           Application
 From a browser, go to URN of the Web
 application




                                         25
Tool: Eclipse 3.7.2




                      26
New > Server > Apache Tomcat 7.0




                                   27
New Dynamic Web Project




                          28
Choose Project Name: Hello and Specify Location




                                                  29
Drag image into Hello




                        30
New HTML File




                31
welcomePage.html




                   32
welcomePage.html

<html>
    <head>
        <title>Hello</title>
    </head>
    <body>
        <form action="result">
            <img src="dukeWaving.png" width="79" height="62"
   /><br>
            <h3> Hello, my name is Duke. What's yours?
   <br><br></h3>
            <input type="text" name="username" /><br><br>
            <input type="submit" value="Submit" />
            <input type="reset" value="Reset" />
        </form>
    </body>
</html>




                                                               33
http://localhost:8080/Hello/welcomePage.html




                                               34
New Servlet…




               35
ResultServlet.java




                     36
ResultServlet.java
protected void doGet(HttpServletRequest request,
   HttpServletResponse response)
    throws ServletException, IOException {

        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();

        String username = request.getParameter("username");
        out.print("<h3> Hello " + username + "</h3>");

        out.close();
}




                                                              37
Test & Result




                38
Web Application
 Web  application can be deployed in two
 different forms
     a *.war file or
     an unpacked directory laid out in the same format
      as a *.war file (build directory)
 Use*.war file when you have to deploy on
 a remote machine

                                                          39
What is *.WAR file?
   Ready to deploy'able package over web container
   Similar to *.jar file
   Contains things to be deployed
        Web components (servlets or JSP's)
        Server-side utility classes
        Static Web presentation content (HTML, image, etc)
        Client-side classes (applets and utility classes)
   Reflects contents in build directory
                                                              40
Document Root & Context
   Document Root of the Web application
       Top-level directory of WAR
       Contains JSP pages, client-side classes and archives, and
        static Web resources are stored
       Also contains WEB-INF directory
   A context is a name that gets mapped to the
    document root of a Web application
       /Hello is context for Hello example
       Distinguishes a Web application in a single Web container
       Has to be specified as part of client URN
                                                                    41
Export to Hello.WAR file




                           42
Directory Structure of *.WAR file




                                    43
WEB-INF Directory
   Subdirectory of Document root
   Contains
       web.xml : Web application deployment descriptor
       JSP tag library descriptor files
       classes : A directory that contains server-side classes:
        servlets, utility classes, and JavaBeans components
       lib : A directory that contains JAR archives of libraries
        (tag libraries and any utility libraries called by server-side
        classes)

                                                                         44
HTTP request URL & Web component
          URN (alias) & Context
   Request URL: User specified access point of a web
    resource
      http://[host]:[port]/[request path]?[query string]
      [request path] is made of context and web component's URN
      http://localhost:8080/Hello/result?username=Thanisa

   Context: Name of the root document of a web
    application – Identifies a particular application on that
    server
        /Hello is context

                                                                   45
Configuring Web Application
 Configuration
             information is specified in
 web.xml (Web Applications Deployment
 Descriptor)




                                           46
Alias Paths (of web.xml)
   When a request is received by Servlet container, it must
    determine which Web component in a which web
    application should handle the request. It does so by
    mapping the URL path contained in the request to a Web
    component
   A URL path contains the context root and alias path
        http://<host>:8080/context_root/alias_path
   Alias Path can be in the form of either
        /alias-string (for servlet) or
        /*.jsp (for JSP)
                                                               47
<?xml version="1.0" encoding="UTF-8"?>
:
    <servlet>
        <servlet-name>ResultServlet</servlet-name>
        <servlet-class>servlets.ResultServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>ResultServlet</servlet-name>
        <url-pattern>/result</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
       <welcome-file>
            welcomePage.html
        </welcome-file>
    </welcome-file-list>
</web-app>

                                                                48
Try to deploy in external Tomcat




                                   49
Control Panel -> Administrative Tools ->
                Services




                                           50
http://localhost:8080/Hello/welcomePage.html




                                               51
Acknowledgement
Some contents are borrowed from the
presentation slides of Sang Shin, Java™
Technology Evangelist, Sun Microsystems,
Inc.




                                           52
Thank you

   thananum@gmail.com
www.facebook.com/imcinstitute
   www.imcinstitute.com



                                53
1 von 53

Recomendados

Introduction to React JS von
Introduction to React JSIntroduction to React JS
Introduction to React JSArno Lordkronos
32.7K views21 Folien
Nodejs presentation von
Nodejs presentationNodejs presentation
Nodejs presentationArvind Devaraj
8.9K views17 Folien
Core java complete ppt(note) von
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)arvind pandey
5.9K views269 Folien
Express js von
Express jsExpress js
Express jsManav Prasad
6.7K views19 Folien
JNDI von
JNDIJNDI
JNDIShobana Pattabiraman
2.8K views40 Folien
Json von
JsonJson
Jsonkrishnapriya Tadepalli
4.3K views29 Folien

Más contenido relacionado

Was ist angesagt?

Introduction To Dotnet von
Introduction To DotnetIntroduction To Dotnet
Introduction To DotnetSAMIR BHOGAYTA
63.2K views30 Folien
JSON: The Basics von
JSON: The BasicsJSON: The Basics
JSON: The BasicsJeff Fox
27.7K views29 Folien
Introduction to node.js von
Introduction to node.jsIntroduction to node.js
Introduction to node.jsjacekbecela
9.4K views60 Folien
Presentation on Core java von
Presentation on Core javaPresentation on Core java
Presentation on Core javamahir jain
95.3K views18 Folien
Event Handling in java von
Event Handling in javaEvent Handling in java
Event Handling in javaGoogle
33.5K views46 Folien
Java tutorial PPT von
Java tutorial PPTJava tutorial PPT
Java tutorial PPTIntelligo Technologies
177.7K views55 Folien

Was ist angesagt?(20)

JSON: The Basics von Jeff Fox
JSON: The BasicsJSON: The Basics
JSON: The Basics
Jeff Fox27.7K views
Introduction to node.js von jacekbecela
Introduction to node.jsIntroduction to node.js
Introduction to node.js
jacekbecela9.4K views
Presentation on Core java von mahir jain
Presentation on Core javaPresentation on Core java
Presentation on Core java
mahir jain95.3K views
Event Handling in java von Google
Event Handling in javaEvent Handling in java
Event Handling in java
Google33.5K views
[Final] ReactJS presentation von 洪 鹏发
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
洪 鹏发30.3K views
jstl ( jsp standard tag library ) von Adarsh Patel
jstl ( jsp standard tag library )jstl ( jsp standard tag library )
jstl ( jsp standard tag library )
Adarsh Patel2.8K views
Introduction to Javascript von Amit Tyagi
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
Amit Tyagi13.5K views
Java Server Pages(jsp) von Manisha Keim
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
Manisha Keim4.5K views
An Introduction To Java Web Technology von vikram singh
An Introduction To Java Web TechnologyAn Introduction To Java Web Technology
An Introduction To Java Web Technology
vikram singh7.3K views
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres... von Edureka!
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js +  Expres...Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js +  Expres...
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres...
Edureka!1.2K views
Java basic tutorial by sanjeevini india von Sanjeev Tripathi
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini india
Sanjeev Tripathi584 views

Similar a Java Web Programming [1/9] : Introduction to Web Application

Intro in JavaEE world (TU Olomouc) von
Intro in JavaEE world (TU Olomouc)Intro in JavaEE world (TU Olomouc)
Intro in JavaEE world (TU Olomouc)blahap
687 views49 Folien
Summer training java von
Summer training javaSummer training java
Summer training javaArshit Rai
1.2K views47 Folien
Summer training java von
Summer training javaSummer training java
Summer training javaArshit Rai
386 views47 Folien
J2 ee architecture von
J2 ee architectureJ2 ee architecture
J2 ee architecturesaurabhshertukde
1.5K views38 Folien
Virtual classroom von
Virtual classroomVirtual classroom
Virtual classroomKrishna Chaithanya
744 views32 Folien
Enterprise application developement von
Enterprise application developementEnterprise application developement
Enterprise application developementArchana Jha
166 views17 Folien

Similar a Java Web Programming [1/9] : Introduction to Web Application(20)

Intro in JavaEE world (TU Olomouc) von blahap
Intro in JavaEE world (TU Olomouc)Intro in JavaEE world (TU Olomouc)
Intro in JavaEE world (TU Olomouc)
blahap687 views
Summer training java von Arshit Rai
Summer training javaSummer training java
Summer training java
Arshit Rai1.2K views
Summer training java von Arshit Rai
Summer training javaSummer training java
Summer training java
Arshit Rai386 views
Enterprise application developement von Archana Jha
Enterprise application developementEnterprise application developement
Enterprise application developement
Archana Jha166 views
Course syllabus from ingenious von Colege Buz
Course syllabus from ingeniousCourse syllabus from ingenious
Course syllabus from ingenious
Colege Buz356 views
Course syllabus from ingenious von Colege Buz
Course syllabus from ingeniousCourse syllabus from ingenious
Course syllabus from ingenious
Colege Buz309 views
J2EE and Servlet von Rishikesh .
J2EE and Servlet J2EE and Servlet
J2EE and Servlet
Rishikesh .940 views
Introduction to java ee von Ranjan Kumar
Introduction to java eeIntroduction to java ee
Introduction to java ee
Ranjan Kumar2.9K views
J2EE and layered architecture von Suman Behara
J2EE and layered architectureJ2EE and layered architecture
J2EE and layered architecture
Suman Behara38.3K views
Intorduction to struts von Anup72
Intorduction to strutsIntorduction to struts
Intorduction to struts
Anup723.4K views
Session 1 Tp1 von phanleson
Session 1 Tp1Session 1 Tp1
Session 1 Tp1
phanleson792 views
Introduction to ejb and struts framework von s4al_com
Introduction to ejb and struts frameworkIntroduction to ejb and struts framework
Introduction to ejb and struts framework
s4al_com1.3K views
Java Web Programming [6/9] : MVC von IMC Institute
Java Web Programming [6/9] : MVCJava Web Programming [6/9] : MVC
Java Web Programming [6/9] : MVC
IMC Institute1.5K views

Más de IMC Institute

นิตยสาร Digital Trends ฉบับที่ 14 von
นิตยสาร Digital Trends ฉบับที่ 14นิตยสาร Digital Trends ฉบับที่ 14
นิตยสาร Digital Trends ฉบับที่ 14IMC Institute
1.1K views40 Folien
Digital trends Vol 4 No. 13 Sep-Dec 2019 von
Digital trends Vol 4 No. 13  Sep-Dec 2019Digital trends Vol 4 No. 13  Sep-Dec 2019
Digital trends Vol 4 No. 13 Sep-Dec 2019IMC Institute
758 views36 Folien
บทความ The evolution of AI von
บทความ The evolution of AIบทความ The evolution of AI
บทความ The evolution of AIIMC Institute
1.8K views10 Folien
IT Trends eMagazine Vol 4. No.12 von
IT Trends eMagazine  Vol 4. No.12IT Trends eMagazine  Vol 4. No.12
IT Trends eMagazine Vol 4. No.12IMC Institute
678 views40 Folien
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation von
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformationเพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital TransformationIMC Institute
1.6K views8 Folien
IT Trends 2019: Putting Digital Transformation to Work von
IT Trends 2019: Putting Digital Transformation to WorkIT Trends 2019: Putting Digital Transformation to Work
IT Trends 2019: Putting Digital Transformation to WorkIMC Institute
744 views15 Folien

Más de IMC Institute(20)

นิตยสาร Digital Trends ฉบับที่ 14 von IMC Institute
นิตยสาร Digital Trends ฉบับที่ 14นิตยสาร Digital Trends ฉบับที่ 14
นิตยสาร Digital Trends ฉบับที่ 14
IMC Institute1.1K views
Digital trends Vol 4 No. 13 Sep-Dec 2019 von IMC Institute
Digital trends Vol 4 No. 13  Sep-Dec 2019Digital trends Vol 4 No. 13  Sep-Dec 2019
Digital trends Vol 4 No. 13 Sep-Dec 2019
IMC Institute758 views
บทความ The evolution of AI von IMC Institute
บทความ The evolution of AIบทความ The evolution of AI
บทความ The evolution of AI
IMC Institute1.8K views
IT Trends eMagazine Vol 4. No.12 von IMC Institute
IT Trends eMagazine  Vol 4. No.12IT Trends eMagazine  Vol 4. No.12
IT Trends eMagazine Vol 4. No.12
IMC Institute678 views
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation von IMC Institute
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformationเพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
IMC Institute1.6K views
IT Trends 2019: Putting Digital Transformation to Work von IMC Institute
IT Trends 2019: Putting Digital Transformation to WorkIT Trends 2019: Putting Digital Transformation to Work
IT Trends 2019: Putting Digital Transformation to Work
IMC Institute744 views
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม von IMC Institute
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรมมูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
IMC Institute911 views
IT Trends eMagazine Vol 4. No.11 von IMC Institute
IT Trends eMagazine  Vol 4. No.11IT Trends eMagazine  Vol 4. No.11
IT Trends eMagazine Vol 4. No.11
IMC Institute693 views
แนวทางการทำ Digital transformation von IMC Institute
แนวทางการทำ Digital transformationแนวทางการทำ Digital transformation
แนวทางการทำ Digital transformation
IMC Institute2.4K views
บทความ The New Silicon Valley von IMC Institute
บทความ The New Silicon Valleyบทความ The New Silicon Valley
บทความ The New Silicon Valley
IMC Institute436 views
นิตยสาร IT Trends ของ IMC Institute ฉบับที่ 10 von IMC Institute
นิตยสาร IT Trends ของ  IMC Institute  ฉบับที่ 10นิตยสาร IT Trends ของ  IMC Institute  ฉบับที่ 10
นิตยสาร IT Trends ของ IMC Institute ฉบับที่ 10
IMC Institute832 views
แนวทางการทำ Digital transformation von IMC Institute
แนวทางการทำ Digital transformationแนวทางการทำ Digital transformation
แนวทางการทำ Digital transformation
IMC Institute2.6K views
The Power of Big Data for a new economy (Sample) von IMC Institute
The Power of Big Data for a new economy (Sample)The Power of Big Data for a new economy (Sample)
The Power of Big Data for a new economy (Sample)
IMC Institute1.6K views
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง von IMC Institute
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
IMC Institute918 views
IT Trends eMagazine Vol 3. No.9 von IMC Institute
IT Trends eMagazine  Vol 3. No.9 IT Trends eMagazine  Vol 3. No.9
IT Trends eMagazine Vol 3. No.9
IMC Institute710 views
Thailand software & software market survey 2016 von IMC Institute
Thailand software & software market survey 2016Thailand software & software market survey 2016
Thailand software & software market survey 2016
IMC Institute821 views
Developing Business Blockchain Applications on Hyperledger von IMC Institute
Developing Business  Blockchain Applications on Hyperledger Developing Business  Blockchain Applications on Hyperledger
Developing Business Blockchain Applications on Hyperledger
IMC Institute1.3K views
Digital transformation @thanachart.org von IMC Institute
Digital transformation @thanachart.orgDigital transformation @thanachart.org
Digital transformation @thanachart.org
IMC Institute2K views
บทความ Big Data จากบล็อก thanachart.org von IMC Institute
บทความ Big Data จากบล็อก thanachart.orgบทความ Big Data จากบล็อก thanachart.org
บทความ Big Data จากบล็อก thanachart.org
IMC Institute5K views
กลยุทธ์ 5 ด้านกับการทำ Digital Transformation von IMC Institute
กลยุทธ์ 5 ด้านกับการทำ Digital Transformationกลยุทธ์ 5 ด้านกับการทำ Digital Transformation
กลยุทธ์ 5 ด้านกับการทำ Digital Transformation
IMC Institute1.6K views

Último

The Role of Patterns in the Era of Large Language Models von
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language ModelsYunyao Li
104 views65 Folien
PCCC23:日本AMD株式会社 テーマ1「AMD Instinct™ アクセラレーターの概要」 von
PCCC23:日本AMD株式会社 テーマ1「AMD Instinct™ アクセラレーターの概要」PCCC23:日本AMD株式会社 テーマ1「AMD Instinct™ アクセラレーターの概要」
PCCC23:日本AMD株式会社 テーマ1「AMD Instinct™ アクセラレーターの概要」PC Cluster Consortium
29 views68 Folien
Business Analyst Series 2023 - Week 4 Session 8 von
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8DianaGray10
180 views13 Folien
The Coming AI Tsunami.pptx von
The Coming AI Tsunami.pptxThe Coming AI Tsunami.pptx
The Coming AI Tsunami.pptxjohnhandby
14 views12 Folien
Mobile Core Solutions & Successful Cases.pdf von
Mobile Core Solutions & Successful Cases.pdfMobile Core Solutions & Successful Cases.pdf
Mobile Core Solutions & Successful Cases.pdfIPLOOK Networks
16 views7 Folien
Future of AR - Facebook Presentation von
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook PresentationRob McCarty
66 views27 Folien

Último(20)

The Role of Patterns in the Era of Large Language Models von Yunyao Li
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language Models
Yunyao Li104 views
PCCC23:日本AMD株式会社 テーマ1「AMD Instinct™ アクセラレーターの概要」 von PC Cluster Consortium
PCCC23:日本AMD株式会社 テーマ1「AMD Instinct™ アクセラレーターの概要」PCCC23:日本AMD株式会社 テーマ1「AMD Instinct™ アクセラレーターの概要」
PCCC23:日本AMD株式会社 テーマ1「AMD Instinct™ アクセラレーターの概要」
Business Analyst Series 2023 - Week 4 Session 8 von DianaGray10
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8
DianaGray10180 views
The Coming AI Tsunami.pptx von johnhandby
The Coming AI Tsunami.pptxThe Coming AI Tsunami.pptx
The Coming AI Tsunami.pptx
johnhandby14 views
Mobile Core Solutions & Successful Cases.pdf von IPLOOK Networks
Mobile Core Solutions & Successful Cases.pdfMobile Core Solutions & Successful Cases.pdf
Mobile Core Solutions & Successful Cases.pdf
IPLOOK Networks16 views
Future of AR - Facebook Presentation von Rob McCarty
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
Rob McCarty66 views
The Power of Heat Decarbonisation Plans in the Built Environment von IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE85 views
Cocktail of Environments. How to Mix Test and Development Environments and St... von Aleksandr Tarasov
Cocktail of Environments. How to Mix Test and Development Environments and St...Cocktail of Environments. How to Mix Test and Development Environments and St...
Cocktail of Environments. How to Mix Test and Development Environments and St...
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And... von ShapeBlue
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
ShapeBlue120 views
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De... von Moses Kemibaro
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Moses Kemibaro38 views
The Power of Generative AI in Accelerating No Code Adoption.pdf von Saeed Al Dhaheri
The Power of Generative AI in Accelerating No Code Adoption.pdfThe Power of Generative AI in Accelerating No Code Adoption.pdf
The Power of Generative AI in Accelerating No Code Adoption.pdf
Saeed Al Dhaheri44 views
Measurecamp Brussels - Synthetic data.pdf von Human37
Measurecamp Brussels - Synthetic data.pdfMeasurecamp Brussels - Synthetic data.pdf
Measurecamp Brussels - Synthetic data.pdf
Human37 27 views
Deep Tech and the Amplified Organisation: Core Concepts von Holonomics
Deep Tech and the Amplified Organisation: Core ConceptsDeep Tech and the Amplified Organisation: Core Concepts
Deep Tech and the Amplified Organisation: Core Concepts
Holonomics17 views
AIM102-S_Cognizant_CognizantCognitive von PhilipBasford
AIM102-S_Cognizant_CognizantCognitiveAIM102-S_Cognizant_CognizantCognitive
AIM102-S_Cognizant_CognizantCognitive
PhilipBasford23 views
"Package management in monorepos", Zoltan Kochan von Fwdays
"Package management in monorepos", Zoltan Kochan"Package management in monorepos", Zoltan Kochan
"Package management in monorepos", Zoltan Kochan
Fwdays37 views
This talk was not generated with ChatGPT: how AI is changing science von Elena Simperl
This talk was not generated with ChatGPT: how AI is changing scienceThis talk was not generated with ChatGPT: how AI is changing science
This talk was not generated with ChatGPT: how AI is changing science
Elena Simperl34 views

Java Web Programming [1/9] : Introduction to Web Application

  • 1. Module 1: Introduction to Web Application Thanisa Krauwaisayawan Thanachart Numnonda www.imcinstitute.com
  • 2. Objectives  Evolution of Enterprise Application Frameworks  Overview: Java EE  Web application, components and Web container  Web application development and deployment steps  Building Simple Web Applications using Eclipse and Tomcat  Web Application Archive (*.WAR file)  *.WAR directory structure  WEB-INF subdirectory  Deploying WAR file to Server 2
  • 3. Evolution of Enterprise Application Framework  Single tier  Two tier  Three tier – RPC based – Remote object based  Three tier (HTML browser and Web server)  Proprietary and standard application server 3
  • 4. Single Tier (Mainframe-based)  Dumb terminals are directly connected to mainframe  Centralized model (as opposed distributed model)  Presentation, business logic, and data access are intertwined in one monolithic mainframe application 4
  • 5. Two-Tier SQL request Database SQL response  Fat clients talking to back end database  SQL queries sent, raw data returned  Presentation,Business logic and Data Model processing logic in client application 5
  • 6. Three-Tier (RPC based) SQL RPC request request Database RPC response SQL response  Thinner client: business & data model separated from presentation  Business logic and data access logic reside in middle tier server while client handles presentation  Middle tier server is now required to handle system services  Concurrency control, threading, transaction, security, persistence, multiplexing, performance, etc. 6
  • 7. Three-Tier (Remote Object based) SQL Object request request Database Object SQL response response  Business logic and data model captured in objects – Business logic and data model are now described in “abstraction” (interface language)  Object models used: CORBA, RMI, DCOM  Interface language in CORBA is IDL  Interface language in RMI is Java interface 7
  • 8. Three-Tier (Web Server) WEB SQL HTML request request Server Database HTML response SQL response  Browser handles presentation logic  Browser talks Web server via HTTP protocol  Business logic and data model are handled by “dynamic contents generation” technologies (CGI, Servlet/JSP, ASP) 8
  • 9. Proprietary and Standard Solution  Comlexity at the middle tier server still remains  Duplicate system services still need to be provided for the majority of enterprise applications – Concurrency control, Transactions – Load-balancing, Security – Resource management, Connection pooling  How to solve this problem? – Commonly shared container that handles the above system services – Proprietary versus standard based
  • 10. JavaTM 2 Platform Java Platform Micro Edition (Java ME) Optional Packages Optional Packages Personal Personal Java Java Basis Profile Profile Enterprise Standard Edition Edition Foundation Profile MIDP (Java EE) (Java SE) CDC Java CLDC Card JVM KVM Card VM 10
  • 11. Overview: Java EE  Java EE is Java SE plus a large number of serverside APIs, containers and tools.  Web Tier to Go With Java EE 6 – Servlet 3.0 (JSR 315) – JavaServer Pages 2.2 (JSR 245)  Many other subsystems standardized under a single platform  EJB, JPA, JMS, JavaMail API, … 11
  • 12. Java EE is End-to-End Solution Firewall Java EE Application Client Server Enterprise Enterprise Information JavaBeans™ Client Systems (EIS): Client Relational Database, Web Enterprise Legacy Client Server JavaBeans Applications, JSP, Servlets ERP Systems Client HTML/XML Other Services: JNDI, JMS, Enterprise Client Middle JavaMail™ Information Tier Tier Tier 12
  • 14. Web Components & Container Applet Container Web Container EJB Container Applet HTTP/ JSP Servlet HTTPS RMI EJB J2SE RMI/IIOP JavaMail RMI/IIOP JavaMail JDBC JDBC JMS JNDI JTA JNDI JMS JTA App Client Container JAF JAF App HTTP/ Client HTTPS J2SE RMI RMI/IIOP JDBC JNDI JMS J2SE J2SE Database 14
  • 15. Web Components & Container  Web components are in the form of either Servlet or JSP (along with JavaBean's and custom tags)  Web components run in a Web container  Tomcat is a popular web containers  All Java EE compliant app servers (GlassFish App Server) provide web containers  Web container provides system services to Web components  Request dispatching, security, and life cycle management
  • 16. Components/Containers Handle Components Containers Handle Handle  Presentation  Concurrency  Business Logic  Security  Availability  Scalability  Persistence  Transaction  Life-cycle management  Management 16
  • 17. Some definitions of the Web Development Process  Web Page:  simple text file consisting of text and HTML tags  Web Browser:  connects to a Web Server, sends a request for a page and receives and displays the result  interprets HTML tags to display the page exactly the way the designer wanted it to be  Web Server:  software which can respond to a Web browser’s request for a page and then send that page to the browser 17
  • 18. Web Application & Components  Web Application is a deployable package  Web components (Servlets and JSP's)  Static resource files such as images  Helper classes  Libraries  Deployment descriptor (web.xml file)  Web Application can be represented as  A hierarchy of directories and files (unpacked form) or  *.WAR file reflecting the same hierarchy (packed form) 18
  • 19. 1. Create Development Tree Structure  KeepWeb application source separate from compiled files – facilitate iterative development  Root directory – src: Java source of servlets and JavaBeans components – WebContent: JSP pages and HTML pages, images 19
  • 20. 2. Create any static resources  HTML pages  welcomePage.html  Imagefiles that are used by HTML pages or JSP pages  Example: dukeWaving.png 20
  • 21. 3. Create deployment descriptor (web.xml)  Deployment descriptor contains deployment time runtime instructions to the Web container  URL that the client uses to access the web component  Every web application has to have it  For Servlet 3.0, web.xml is optional. 21
  • 22. 4. Build the Web application  Build process is made of  create build directory (if it is not present) and its subdirectories  compile Java code into build/classes directory 22
  • 23. Example: Hello Tree Structure  Hello – build/classes • ResultServlet.class – src • ResultServlet.java – WebContent • WEB-INF • META-INF • welcomePage.html • dukeWaving.png 23
  • 24. 5. Deploy Web application  Deploy the application over deployment platform such as Sun Java System App Server or Tomcat 24
  • 25. 6. Perform Client Access to Web Application  From a browser, go to URN of the Web application 25
  • 27. New > Server > Apache Tomcat 7.0 27
  • 28. New Dynamic Web Project 28
  • 29. Choose Project Name: Hello and Specify Location 29
  • 30. Drag image into Hello 30
  • 33. welcomePage.html <html> <head> <title>Hello</title> </head> <body> <form action="result"> <img src="dukeWaving.png" width="79" height="62" /><br> <h3> Hello, my name is Duke. What's yours? <br><br></h3> <input type="text" name="username" /><br><br> <input type="submit" value="Submit" /> <input type="reset" value="Reset" /> </form> </body> </html> 33
  • 37. ResultServlet.java protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); String username = request.getParameter("username"); out.print("<h3> Hello " + username + "</h3>"); out.close(); } 37
  • 39. Web Application  Web application can be deployed in two different forms  a *.war file or  an unpacked directory laid out in the same format as a *.war file (build directory)  Use*.war file when you have to deploy on a remote machine 39
  • 40. What is *.WAR file?  Ready to deploy'able package over web container  Similar to *.jar file  Contains things to be deployed  Web components (servlets or JSP's)  Server-side utility classes  Static Web presentation content (HTML, image, etc)  Client-side classes (applets and utility classes)  Reflects contents in build directory 40
  • 41. Document Root & Context  Document Root of the Web application  Top-level directory of WAR  Contains JSP pages, client-side classes and archives, and static Web resources are stored  Also contains WEB-INF directory  A context is a name that gets mapped to the document root of a Web application  /Hello is context for Hello example  Distinguishes a Web application in a single Web container  Has to be specified as part of client URN 41
  • 43. Directory Structure of *.WAR file 43
  • 44. WEB-INF Directory  Subdirectory of Document root  Contains  web.xml : Web application deployment descriptor  JSP tag library descriptor files  classes : A directory that contains server-side classes: servlets, utility classes, and JavaBeans components  lib : A directory that contains JAR archives of libraries (tag libraries and any utility libraries called by server-side classes) 44
  • 45. HTTP request URL & Web component URN (alias) & Context  Request URL: User specified access point of a web resource  http://[host]:[port]/[request path]?[query string]  [request path] is made of context and web component's URN  http://localhost:8080/Hello/result?username=Thanisa  Context: Name of the root document of a web application – Identifies a particular application on that server  /Hello is context 45
  • 46. Configuring Web Application  Configuration information is specified in web.xml (Web Applications Deployment Descriptor) 46
  • 47. Alias Paths (of web.xml)  When a request is received by Servlet container, it must determine which Web component in a which web application should handle the request. It does so by mapping the URL path contained in the request to a Web component  A URL path contains the context root and alias path  http://<host>:8080/context_root/alias_path  Alias Path can be in the form of either  /alias-string (for servlet) or  /*.jsp (for JSP) 47
  • 48. <?xml version="1.0" encoding="UTF-8"?> : <servlet> <servlet-name>ResultServlet</servlet-name> <servlet-class>servlets.ResultServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>ResultServlet</servlet-name> <url-pattern>/result</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file> welcomePage.html </welcome-file> </welcome-file-list> </web-app> 48
  • 49. Try to deploy in external Tomcat 49
  • 50. Control Panel -> Administrative Tools -> Services 50
  • 52. Acknowledgement Some contents are borrowed from the presentation slides of Sang Shin, Java™ Technology Evangelist, Sun Microsystems, Inc. 52
  • 53. Thank you thananum@gmail.com www.facebook.com/imcinstitute www.imcinstitute.com 53