INTRODUCTION TO SERVLETS AND WEB CONTAINERS. Actions in Accord with All the Laws of Nature

Similar documents
JAVA SERVLET. Server-side Programming INTRODUCTION

Java Enterprise Edition. Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 1

Advanced Internet Technology Lab # 4 Servlets

Servlets1. What are Servlets? Where are they? Their job. Servlet container. Only Http?

Servlet Basics. Agenda

LAB 1 PREPARED BY : DR. AJUNE WANIS ISMAIL FACULTY OF COMPUTING UNIVERSITI TEKNOLOGI MALAYSIA

HttpServlet ( Class ) -- we will extend this class to handle GET / PUT HTTP requests

Servlets by Example. Joe Howse 7 June 2011

Unit-4: Servlet Sessions:

Servlets and JSP (Java Server Pages)

SSC - Web applications and development Introduction and Java Servlet (I)

Stateless -Session Bean

Advanced Topics in Operating Systems. Manual for Lab Practices. Enterprise JavaBeans

Session 8. Introduction to Servlets. Semester Project

Session 9. Introduction to Servlets. Lecture Objectives

Enterprise Java Technologies (Part 1 of 3) Component Architecture. Overview of Java EE. Java Servlets

Introduction. This course Software Architecture with Java will discuss the following topics:

The Basic Web Server CGI. CGI: Illustration. Web based Applications, Tomcat and Servlets - Lab 3 - CMPUT 391 Database Management Systems 4

Introduction to Java Servlets. SWE 432 Design and Implementation of Software for the Web

Web based Applications, Tomcat and Servlets - Lab 3 -

Advanced Web Technology

Introduction. Literature: Steelman & Murach, Murach s Java Servlets and JSP. Mike Murach & Associates Inc, 2003

********************************************************************

Database Applications Recitation 6. Project 3: CMUQFlix CMUQ s Movies Recommendation System

Servlet Fudamentals. Celsina Bignoli

Accessing EJB in Web applications

Lab session Google Application Engine - GAE. Navid Nikaein

Connecting the RISC Client to non-javascriptinterfaces

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2

Java servlets CSCI 470: Web Science Keith Vertanen Copyright 2013

ServletConfig Interface

sessionx Desarrollo de Aplicaciones en Red A few more words about CGI CGI Servlet & JSP José Rafael Rojano Cáceres

AJP. CHAPTER 5: SERVLET -20 marks

Servlets. An extension of a web server runs inside a servlet container

This tutorial will teach you how to use Java Servlets to develop your web based applications in simple and easy steps.

A.1 JSP A.2 JSP JSP JSP. MyDate.jsp page contenttype="text/html; charset=windows-31j" import="java.util.calendar" %>

Advance Java. Configuring and Getting Servlet Init Parameters per servlet

Introduction to Servlets. After which you will doget it

CE212 Web Application Programming Part 3

WHITE LABELING IN PROGRESS ROLLBASE PRIVATE CLOUD

SERVLETS INTERVIEW QUESTIONS

Implementation Architecture

Introduction. This course Software Architecture with Java will discuss the following topics:

CIS 3952 [Part 2] Java Servlets and JSP tutorial

Unit 4 - Servlet. Servlet. Advantage of Servlet

Enterprise Development

Questions and Answers

Servlet. Web Server. Servlets are modules of Java code that run in web server. Internet Explorer. Servlet. Fire Fox. Servlet.

2. Follow the installation directions and install the server on ccc. 3. We will call the root of your installation as $TOMCAT_DIR

Web Application Services Practice Session #2

Handout 31 Web Design & Development

Kamnoetvidya Science Academy. Object Oriented Programming using Java. Ferdin Joe John Joseph. Java Session

Enterprise Java Unit 1- Chapter 4 Prof. Sujata Rizal Servlet API and Lifecycle

4.1 The Life Cycle of a Servlet 4.2 The Java Servlet Development Kit 4.3 The Simple Servlet: Creating and compile servlet source code, start a web

Chettinad College of Engineering and Technology CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE AND TECHNOLOGY

Servlet. 1.1 Web. 1.2 Servlet. HTML CGI Common Gateway Interface Web CGI CGI. Java Applet JavaScript Web. Java CGI Servlet. Java. Apache Tomcat Jetty

Module 4: SERVLET and JSP

Implementation Architecture

Fast Track to Java EE

CSC309: Introduction to Web Programming. Lecture 8

JavaServer Pages (JSP)

To follow the Deitel publishing program, sign-up now for the DEITEL BUZZ ON-

JdbcResultSet.java. import java.sql.*;

Java4570: Session Tracking using Cookies *

Introduction. This course Software Architecture with Java will discuss the following topics.

Chapter 10 Servlets and Java Server Pages

COMP9321 Web Application Engineering

COMP9321 Web Application Engineering

Using Java servlets to generate dynamic WAP content

CSC309: Introduction to Web Programming. Lecture 10

Develop an Enterprise Java Bean for Banking Operations

1Z Java EE 6 Web Component Developer Certified Expert Exam Summary Syllabus Questions

Java Servlets. Preparing your System

Contents at a Glance

Web. 2 Web. A Data Dependency Graph for Web Applications. Web Web Web. Web. Web. Java. Web. Web HTTP. Web

Enterprise Java Unit 1- Chapter 3 Prof. Sujata Rizal Introduction to Servlets

Chapter 2 How to structure a web application with the MVC pattern

Servlet and JSP Review

Three hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. Date: Friday 21 st May Time:

JAVA SERVLET. Server-side Programming ADVANCED FEATURES

11.1 Introduction to Servlets

Database Systems Lab. 11. JSP I 충남대학교컴퓨터공학과 데이타베이스시스템연구실

The Servlet Life Cycle

Table of Contents Fast Track to JSF 2

Servlet And JSP. Mr. Nilesh Vishwasrao Patil, Government Polytechnic, Ahmednagar. Mr. Nilesh Vishwasrao Patil

Fast Track to Java EE 5 with Servlets, JSP & JDBC

Cloud Computing Platform as a Service

CS 112 Introduction to Programming

UNIT-V. Web Servers: Tomcat Server Installation:

JAVA SERVLET. Server-side Programming PROGRAMMING

Get the cookies from the service request: Cookie[] HttpServletRequest.getCookies() Add a cookie to the service response:

Welcome To PhillyJUG. 6:30-7:00 pm - Network, eat, find a seat 7:00-7:15 pm - Brief announcements 7:15-8:30 pm - Tom Janofsky's presentation

Module 3 Web Component

Distributed Systems 1

INTERNET PROGRAMMING TEST-3 SCHEME OF EVALUATION 1.A 3 LIFE CYCLE METHODS - 3M 1.B HTML FORM CREATION - 2 M

Component Based Software Engineering

COURSE DETAILS: CORE AND ADVANCE JAVA Core Java

Session 8. JavaBeans. Reading & Reference. Reading. Reference. Session 8 Java Beans. 2/27/2013 Robert Kelly, Head First Chapter 3 (MVC)

Supplement IV.E: Tutorial for Tomcat For Introduction to Java Programming By Y. Daniel Liang

SERVLET AND JSP FILTERS

Transcription:

INTRODUCTION TO SERVLETS AND WEB CONTAINERS Actions in Accord with All the Laws of Nature

Web server vs web container Most commercial web applications use Apache proven architecture and free license. Tomcat can act as simple web server for production environments it may lack features like loadbalancing, redundancy, etc. Glassfish is like Tomcat, but is also JEE container TomEE?

Web container and servlet architecture A servlet is a Java class that extends the capabilities of servers that host applications access by means of a request-response programming model.

World s simplest possible servlet demo Read the steps for demo1 Note the following: The html page (why is it called index.jsp?) What will happen when you click on the hyperlink? <a href='simplestservlet'>simplestservletdemo</a> When will doget be called and what will it do? When will dopost be called and what will it do? Try implementing it (follow the steps carefully, especially 13) Now you know how to implement a web app in Netbeans!

SimplestServlet public class SimplestServlet extends HttpServlet { @Override protected void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getwriter(); out.print("<html><head><title>test</title></head><body>"); out.print("<form method='post'>"); out.print("<p>please click the button</p>"); out.print("<input type='submit' value='click me'/>"); out.print("</form>"); out.print("</body></html>"); } @Override protected void dopost(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getwriter(); out.print("<html><head><title>test</title></head><body>"); out.print("<p>postback received</p>"); out.print("</body></html>"); } }

web.xml <web-app > <servlet> <servlet-name>simplestservlet</servlet-name> <servlet-class>mum.cs545.simplestservlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>simplestservlet</servlet-name> <url-pattern>/simplestservlet</url-pattern> </servlet-mapping> <session-config> </session-config> </web-app>

Main Point 1 Servlets are the basis of dynamic web applications. Servlets process information from a request object and generate new information in a response object. Science of Consciousness: Analogously, humans also operate by giving responses to requests. Response are more likely to be correct and appropriate to the extent that one has broad awareness to consider all relevant information and fine focus to understand the request.

Dynamic versus static pages http request Browser Web Server http response Dynamic page generator Static pages

Web server with Servlet container

Containers provide fundamental support network communications communicating with web server lifecycle management no main method in a servlet, concurrency state management session and context attributes security Support for JSP (JSF, JPA, JTA, EJB, )

How container handles an HTTP request Browser http request Web container service request Servlet http response thread response Container receives new request for a servlet Creates HttpServletRequest and HttpServletResponse objects Calls service method on HttpServlet object in thread When thread completes, converts response object into HTTP response message

Main Point 2 Web containers provide essential support services for servlets. Science of Consciousness: Experience of the unified field of pure consciousness provides essential support services for broad awareness and fine focus in the individual.

The simple web server becomes a (mylet) container Inspect the code for demo 2 The red lines have been added to make the simple web server from lesson 1 into a mylet container What s a mylet?

Servlet life cycle Does not exist. Load. Create. Init. Service. Destroy construct Init() initialized destroy() service() 1 instance of servlet new thread created for every request Then service() called on the thread All threads share instance variables Each thread has own stack for local variables Compare with mylets

Servlet life cycle (related to mylet container) 1. Load servlet class (Class c = Class.forname(...)) 2. Instantiate servlet (c.newinstance()); 3. init() called only once in the servlet's life. Must complete before Container can call service(). 4. service() (called for each request, each request runs in a separate thread) 5. destroy() (called only once)

Main Point 3 Web containers manage the life cycle of servlets. Science of Consciousness: The unified field manages the entire universe, and by experiencing this field of awareness on a regular basis we spontaneously act more and more in accord with all the laws of nature.