Web applications basics l.jpg
This presentation is the property of its rightful owner.
Sponsored Links
1 / 34

Web Applications Basics PowerPoint PPT Presentation

  • Uploaded on
  • Presentation posted in: General

Web Applications Basics. Introduction to Web. Web features Clent/Server HTTP HyperText Markup Language URL addresses Web server - a computer program that is responsible for accepting HTTP requests from clients and serving them HTTP responses

Download Presentation

Web Applications Basics

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

Web applications basics l.jpg

Web Applications Basics

Introduction to web l.jpg

Introduction to Web

  • Web features

    • Clent/Server

    • HTTP

    • HyperText Markup Language

    • URL addresses

  • Web server - a computer program that is responsible for accepting HTTP requests from clients and serving them HTTP responses

  • Web application- a dynamic extension of a web or application server

Web applications components l.jpg

Web Applications & Components

  • Two types of web applications:

    • Presentation-oriented (HTML, XML pages)

    • Service-oriented (Web services)

  • Web components provide the dynamic extension capabilities for a web server:

    • Java servlets

    • JSP pages

    • Web service endpoints

Web application interaction l.jpg

Web Application Interaction

  • [client] sends an HTTP request to the web server

  • [web server]HTTP request HTTPServletRequest

  • This object is delivered to a web component, which can interact with JavaBeans or a DB to generate dynamic content

  • [web component] generates an HTTPServletResponse or pass the request to another web component

  • [web server]HTTPServletResponse HTTP response

  • [web server] returns HTTP response to the client

Web application interaction5 l.jpg

Web Application Interaction

Web components l.jpg

Web Components

  • Servlets- Java classes that dynamically process requests and construct responses

  • JSP pages - text-based documents that execute as servlets but allow a more natural approach to creating static content

  • Appropriate usage

    • Servlets - service-oriented applications, control functions

    • JSP - generating text-based markup (HTML, SVG, WML, XML)

Java web application technologies l.jpg

Java Web Application Technologies

Java Servlet technology is the foundation of all the web application technologies

Web containers l.jpg

Web Containers

  • Web components are supported by the services of a runtime platform called a web container

  • In J2EE, a web container "implements the web component contract of the J2EE architecture“

  • Web container services:

    • request dispatching

    • security

    • concurrency

    • life-cycle management

    • naming, transactions, email APIs

Web container examples l.jpg

Web Container Examples

  • Non-commercial

    • Apache Tomcat

    • Jetty

  • Commertial

    • Sun Java System Application Server

    • BEA WebLogic Server

    • Oracle Application Server

    • WebSphere

  • Open source

    • JBoss

Deployment l.jpg


  • Web components have to be installed or deployed to the web container

  • Aspects of web application behaviour can be configured during application deployment

  • The configuration information is maintained in a XML file called a web application deployment descriptor

Web application development l.jpg

Web Application Development

  • A web application consists of:

    • Web components

    • Static resource files (such as images)

    • Helper classes and libraries

  • The process for creating and running a web application is different from that of traditional stand-alone Java classes

Development cycle l.jpg

Development Cycle

  • Develop the web component code

  • Develop the web application deployment descriptor

  • Compile the web application components and helper classes referenced bythe components

  • Optionally package the application into a deployable unit

  • Deploy the application into a web container

  • Access a URL that references the web application

Web modules l.jpg

Web Modules

  • According to Java EE architecture and Java Servlet Specification:

    • Web components and static web content files such asimages are called web resources

    • A web module is the smallest deployable andusable unit of web resources

    • Web module corresponds to a webapplication

  • A web module has a specific structure

Web module structure l.jpg

Web Module Structure

  • The top-level directory

    of a web moduleis the

    document root of

    the application

  • The document root contains:

    • JSP pages

    • client-side classes

    • client-side archives

    • static web resources

Web module structure15 l.jpg

Web Module Structure

  • The document root contains

    a subdirectory /WEB-INF/

  • web.xml: web application

    deployment descriptor

  • lib: JAR archives of

    libraries called by

    server-side classes

Web module structure16 l.jpg

Web Module Structure

  • classes: server-side classes:

    • servlets

    • utility classes

    • JavaBeans components

  • tags: tag files, which are

    implementations of

    tag libraries

Configuring web applications l.jpg

Configuring Web Applications

  • Web applications are configured via /WEB-INF/web.xml file

  • Configuration options:

    • Map URLs to web components

    • Set initialization parameters

    • Map errors to error screens

    • Declare welcome files

    • Declare resource references

Mapping urls to web components l.jpg

Mapping URLs to Web Components

  • When a request is received by the web container it must determine which web component should handle the request

  • Need to add a servlet definition and a servlet mapping for each servlet to web.xml file









Initialization parameters l.jpg

Initialization Parameters

  • It's possible to pass initialization parameters to the context or to a web component

  • Context parameters:





  • Servlet parameters (within servlet definition):





Handling errors l.jpg

Handling Errors

  • Web container generates default error page

  • You can specify custom default page to be displayed instead

  • Steps to handle errors

    • Create appropriate error html pages for error conditions

    • Modify the web.xml accordingly

Example setting error pages l.jpg

Example: Setting Error Pages



















Example web xml l.jpg

Example: web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-appPUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN“"http://java.sun.com/dtd/web-app_2_3.dtd">


<display-name>Your team project name</display-name>

<description>Team N servlets</description>














War files l.jpg

WAR Files

  • A web module can be deployed as an unpacked file structure or can be packaged in a JAR file known as a Web Archive File

  • WAR file can be created by:

    • executing jar command

    • using Ant target

    • using IDE (Eclipse for instance)

    • using Maven

Setting a context root l.jpg

Setting a Context Root

  • A context rootidentifies a web application in a Java EE server

  • The server is responsible for mapping URL’s that start with a specific prefix to the location of a web application

  • Usually this is done with a web server configuration file

Using maven jetty l.jpg

Using Maven & Jetty

  • A convenient way to develop, build, deploy and run Web application is by using:

  • Maven build tool


  • Jetty web server


Creating directory structure l.jpg

Creating Directory Structure

  • Maven 2 supports the notion of creating a complete project template with a simple command

  • To create Web project template need to use maven-archetype-webapp archetype

mvn archetype:create




Maven web directory structure l.jpg

Maven Web Directory Structure


- directory structure for a WAR

Packaging l.jpg


  • Executing the command

    mvn package

    creates a WAR file

Running with jetty l.jpg

Running with Jetty

  • It’s easy to run application by using Jetty plugin for Maven

  • Jetty is an open-source, standards-based, full-featured web server implemented entirely in Java

  • First created in 1995

  • Latest version 6.1.5 / July 23, 2007

Running with jetty30 l.jpg

Running with Jetty

  • Add the Jetty plugin to the pom.xml











Running with jetty31 l.jpg

Running with Jetty

  • Execute mvn jetty:run command

>mvn jetty:run

[INFO] Scanning for projects...

[INFO] Searching repository for plugin with prefix: 'jetty'.

[INFO] -----------------------------------------------------


[INFO] Building maven2example_webapp Maven Webapp

[INFO] task-segment: [jetty:run]

[INFO] -----------------------------------------------------


[INFO] Starting jetty 6.0.1 ...


[INFO] Started Jetty Server

  • Stop by Ctrl+C

Opening the application l.jpg

Opening the Application

Open your web browser to


Opening the application33 l.jpg

Opening the Application

Valid URL is


Re sources l.jpg


  • J2EE Tutorial “Getting Started with Web applications”


  • Building Web Applications with Maven 2


  • Filmiņa par Web 2 (5 minūtes)


  • Login