5-8 Lect Servlet1

Embed Size (px)

Citation preview

  • 8/7/2019 5-8 Lect Servlet1

    1/13

    Session 1

    Web Applications and

    Servlets

  • 8/7/2019 5-8 Lect Servlet1

    2/13

    Session Objectives

    Explain Web based application architecture

    Explain the working of a webserver Describe the basics of HTTP

    List and compare various server sidetechnologies

    Describe the advantages of using servlets

    Explore a servlets basic structure

  • 8/7/2019 5-8 Lect Servlet1

    3/13

    Exit

    Bill

    ------

    ------

    A Day In A Typical Restaurant

    This system runs smoothly runs with a few customer

    Then the money

    is paidThe customer asks

    for the bill

    A Waiter Accept the order

    and then serves food

    The customerleaves the

    restaurant

    A customer enters

    the restaurant

  • 8/7/2019 5-8 Lect Servlet1

    4/13

    An example - McDonalds a Chain of Restaurants

    Order

    A customer enters

    the restaurant

    Collects the

    items and leavesPays the bill

    He places the order

    He goes to the

    counter...

    Back end Chef

    Food

    Counter

  • 8/7/2019 5-8 Lect Servlet1

    5/13

    A Typical Restaurant

    Client

    Places order Passes it

    Sends back the

    processed order

    ServesWaiter Chef

    The restaurant may need to be expanded

    Increased cost

    Greater InvestmentThis can be a solution but

    incase customers want to

    place orders from a remote

    location, then the web can

    come to rescue

  • 8/7/2019 5-8 Lect Servlet1

    6/13

    The Web Based Solution -New way of doing

    business - E-commerce

    Web Server

    receives request

    (Waiter)

    Places order HTTP request

    Servlets act

    as Chefs

    Client Browser

    Checks the

    restaurant

    database

    Items are Present

    Requests for Items

    Dish

    Ready

    Information sent back to

    client as an HTTP response

  • 8/7/2019 5-8 Lect Servlet1

    7/13

    The Web Application Architecture

    Application Layer(2ndTier)

    Response

    Request

    Presentation Layer(1stTier)

    Web

    BrowserWeb Server

    Server Script a

    Server side

    program in Servlet

    Data Stores

    Data

    Assembling

    Database Layer

    (3rdTier)

    Web

    Page

    Webpage:Atext filecontainingtextalong withasetofHTML tags.

    Awebserver respondstoa webbrowsers request forapageand

    sends ittothe webbrowserthroughtheInternet

    Webbrowser: Connectstoa Web Serverand interpretsasetofHTML tagswithin apagetodisplaythepageonthescreen.

  • 8/7/2019 5-8 Lect Servlet1

    8/13

    Various Server side Technologies

    Java Server

    Pages (JSP)

    Server-side

    Java Scripts (SSJS)Java Servlets

    Proprietary Web serverAPIs (ISAPI, NSAPI)

    Active Server

    Pages (ASP)

    Common GatewayInterface(CGI)

    PHP

    Server side Technologies

  • 8/7/2019 5-8 Lect Servlet1

    9/13

    How we see our web applicationYou use HTMLto say what aweb page is

    and css to sayhow the page

    should look

    Var requestFunction

    {

    }

    request

    response

    Web server

  • 8/7/2019 5-8 Lect Servlet1

    10/13

    Web Server

    Server can support multiple concurrent

    services

    The Java Web Server is an instance of the

    JVM

    It may start several

    services such as theHTTP service, Administrative service and

    Web Proxy Service

  • 8/7/2019 5-8 Lect Servlet1

    11/13

    Servlets-defined Java objects which are based on

    servlet framework and APIs and extend

    the functionality of a HTTP server. Mapped to URLs and managed by

    container with a simple architecture

    Available and running on all major webservers and app servers

    Platform and server independent

  • 8/7/2019 5-8 Lect Servlet1

    12/13

    Advantages of Servlets

    Loaded in the same

    process space as the

    web server

    Faster than common

    scripting languages

    More secure and almost

    crash proof

    Durable objects. Remain

    in memory until

    destroyed explicitly

    Completely protocol

    independent

    Advantages

  • 8/7/2019 5-8 Lect Servlet1

    13/13

    Working of Servlet

    HTTP

    Services