Chapter 2 Web app architecture. High-level web app architecture  When a client request coming in and needs servlet to serve dynamic web content, what.

Slides:



Advertisements
Similar presentations
Servlets & JSPs - Sharad Ballepu.
Advertisements

 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
Introduction to Servlets Based on: Hall, Brown, Core Servlets and JavaServer Pages.
J.Sant Servlets Joseph Sant Sheridan Institute of Technology.
Objectives Ch. D - 1 At the end of this chapter students will: Know the general architecture and purpose of servlets Understand how to create a basic servlet.
Servlets Stoney Jackson
MC365 Application Servers: Servlets. Today We Will Cover: What a servlet is The HTTPServlet and some of its more important methods How to configure the.
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
JSP Java Server Pages Reference:
1 CS6320 – Servlet Structure and Lifecycle L. Grewe.
27-Jun-15 Directories and DDs. 2 Web apps A web application is basically a web site that: “Knows who you are”--it doesn’t just give you static pages,
Introduction to Servlet & JSP
Comp2513 Java Servlet Basics Daniel L. Silver, Ph.D.
Java Server and Servlet CS616 Team 9 Kim Doyle, Susan Kroha, Arunima Palchowdhury, Wei Xu.
Chapter 4 Servlets Concept of Servlets (What, Why, and How) Servlet API Third-party tools to run servlets Examples of Using Servlets HTML tag with GET.
Server Side Programming Web Information Systems 2012.
Servlets Life Cycle. The Servlet Life Cycle A servlet life cycle can be defined as the entire process from its creation till the destruction. The following.
Servlets. Our Project 3-tier application Develop our own multi-threaded server Socket level communication.
SE-2840 Dr. Mark L. Hornick1 Java Servlet-based web apps Servlet Architecture.
Java Servlets and JSP.
Java Servlets. What Are Servlets? Basically, a java program that runs on the server Basically, a java program that runs on the server Creates dynamic.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Servlets. - Java technology for Common Gateway Interface (CGI) programming. - It is a Java class that dynamically extends the function of a web server.
AN OVERVIEW OF SERVLET TECHNOLOGY SERVER SETUP AND CONFIGURATION WEB APPLICATION STRUCTURE BASIC SERVLET EXAMPLE Java Servlets - Compiled By Nitin Pai.
Objectives Java Servlet Web Components
Functionality of a web server What does the web server do? Let a user request a resource Find the resource Return something to the user The resource can.
SKT-SSU IT Training Center Servlet and JSP. Chapter Three: Servlet Basics.
111 Java Servlets Dynamic Web Pages (Program Files) Servlets versus Java Server Pages Implementing Servlets Example: F15 Warranty Registration Tomcat Configuration.
COMP 321 Week 7. Overview HTML and HTTP Basics Dynamic Web Content ServletsMVC Tomcat in Eclipse Demonstration Lab 7-1 Introduction.
CMPUT 391 – Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems Web based Applications,
Servlet Lifecycle Lec 28. Servlet Life Cycle  Initialize  Service  Destroy Time.
Chapter 3 Servlet Basics. 1.Recall the Servlet Role 2.Basic Servlet Structure 3.A simple servlet that generates plain text 4.A servlet that generates.
Java Servlets & Java Server Pages Lecture July 2013.
Java Servlets Lec 27. Creating a Simple Web Application in Tomcat.
20-Nov-15introServlets.ppt Intro to servlets. 20-Nov-15introServlets.ppt typical web page – source Hello Hello.
@2008 Huynh Ngoc Tin Chapter #2 JAVA SERVLET PRGRAMMING.
JSP Pages. What and Why of JSP? JSP = Java code imbedded in HTML or XML –Static portion of the page is HTML –Dynamic portion is Java Easy way to develop.
Middleware 3/29/2001 Kang, Seungwoo Lee, Jinwon. Description of Topics 1. CGI, Servlets, JSPs 2. Sessions/Cookies 3. Database Connection(JDBC, Connection.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
CS320 Web and Internet Programming Introduction to Java Servlets Chengyu Sun California State University, Los Angeles.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
Configuration Web Server Tomcat - Install JDK Install Tom cat Configure Tom cat for running Servlet C:\Program Files\Apache Software Foundation\Tomcat.
©SoftMoore ConsultingSlide 1 Overview of Servlets and JavaServer Pages (JSP)
HTTP protocol Java Servlets. HTTP protocol Web system communicates with end-user via HTTP protocol HTTP protocol methods: GET, POST, HEAD, PUT, OPTIONS,
Chapter 4 Request and Response. Servlets are controlled by the container.
Bayu Priyambadha, S.Kom. Static content  Web Server delivers contents of a file (html) 1. Browser sends request to Web Server 3. Web Server sends HTML.
S ERVLETS Form Data 19-Mar-16. F ORM P ROCESSING You must have come across many situations when you need to pass some information from your browser to.
CS320 Web and Internet Programming Introduction to Java Servlets Chengyu Sun California State University, Los Angeles.
Distributed Web Systems Java Servlets Lecturer Department University.
CS3220 Web and Internet Programming Introduction to Java Servlets
Building Web Apps with Servlets
Servlet Fudamentals.
Java Servlets By: Tejashri Udavant..
CSE 403: Servlet Technology
Net-centric Computing
Course Outcomes of Advanced Java Programming AJP (17625, C603)
Servlets and JSP 20-Nov-18 servletsJSP.ppt.
Java Servlets and JSP.
CS3220 Web and Internet Programming Introduction to Java Servlets
Servlets.
J2EE Lecture 1:Servlet and JSP
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Directories and DDs 25-Apr-19.
Introduction to Servlet
Basic servlet structure
Directories and DDs 21-Jul-19.
Directories and DDs 14-Sep-19.
Java Chapter 7 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Chapter 2 Web app architecture

High-level web app architecture  When a client request coming in and needs servlet to serve dynamic web content, what has to be done? Somebody has to instantiate the servlet Somebody has to instantiate the servlet Somebody has to make a new thread to handle the request Somebody has to make a new thread to handle the request Somebody has to call the servlet’s doPost() or doGet() method Somebody has to call the servlet’s doPost() or doGet() method Somebody has to get the request and the response to the servlet Somebody has to get the request and the response to the servlet Somebody has to manage the life, death, and resources of the servlet Somebody has to manage the life, death, and resources of the servlet  That somebody is the web container

What is a Container  Servlets don’t have a main() method  They are under control of another Java application called a Container Tomcat is an example of a Container Tomcat is an example of a Container Example: import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class Ch1Servlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { PrintWriter out = response.getWriter(); PrintWriter out = response.getWriter(); java.util.Date today = new java.util.Date(); java.util.Date today = new java.util.Date(); out.println(" " + out.println(" " + " "+ " "+ " HF\'s Chapter1 Servlet " " HF\'s Chapter1 Servlet " + " "+today+" "+" "); + " "+today+" "+" "); }}

What is a container  When your web server (like Apache) gets a request for a servlet, the server hands the request not to the servlet itself, but to the container in which the servlet is deployed  Container gives the servlet the request and gets the response from the servlet

What does the container give you?  Communication support The container provides an easy way for your servlets to talk to your web server The container provides an easy way for your servlets to talk to your web server Otherwise, the servlets may need to create sockets in order to communicate with the web serverOtherwise, the servlets may need to create sockets in order to communicate with the web server  Lifecycle Management The container controls the life and death of your servlets The container controls the life and death of your servlets The container takes care of The container takes care of Loading the classesLoading the classes Instantiating and initializing the servletsInstantiating and initializing the servlets Invoking the servlet methodsInvoking the servlet methods Making servlet instances eligible for garbage collectionMaking servlet instances eligible for garbage collection

What does the container give you?  Multithreading support The container automatically creates a new Java thread for every servlet request it receives The container automatically creates a new Java thread for every servlet request it receives When the servlet’s done running the HTTP service method for one client’s request, the thread completes (dies) When the servlet’s done running the HTTP service method for one client’s request, the thread completes (dies) But the servlet does not die, it may have several other running threads serving other client’s requests to the same servletBut the servlet does not die, it may have several other running threads serving other client’s requests to the same servlet

What does the container give you?  Declarative Security With a container, you can use an XML deployment descriptor to configure (and modify) security without having to hard-code it With a container, you can use an XML deployment descriptor to configure (and modify) security without having to hard-code it You do not have to hard-code it into your servlet class code You do not have to hard-code it into your servlet class code  JSP support Container takes care of translating JSP code into Java code Container takes care of translating JSP code into Java code

How the container handles a request

How the container handles the request

How the container finds the servlet  The URL that comes in as part of the request from the client is mapped to a specific servlet on the server  It is up to the developer/deployer to configure the mapping

A servlet can have THREE names  Client-known URL name Or sometimes called pubic URL name Or sometimes called pubic URL name  Deployer-known secret internal name Or sometimes called deployment name Or sometimes called deployment name  Actual file name The developer gives a name to the servlet class The developer gives a name to the servlet class

A servlet can have THREE names  Mapping servlet names improves your app’s flexibility and security By mapping the name instead of coding in the real file and path name, you have the flexibility to move things around By mapping the name instead of coding in the real file and path name, you have the flexibility to move things around You do not want the client to know exact how things are structured on your server You do not want the client to know exact how things are structured on your server If the end-user can see the real path, she can type it into her browser and try to access it directlyIf the end-user can see the real path, she can type it into her browser and try to access it directly

Deployment Descriptor can map URLs to servlets  The two Deployment Descriptor (DD) elements for URL mapping: Maps internal name to fully-qualified class nameMaps internal name to fully-qualified class name Maps internal name to public URL nameMaps internal name to public URL name