Copyright © 2002 ProsoftTraining. All rights reserved. Java Servlets.

Slides:



Advertisements
Similar presentations
Internet i jego zastosowania 1 J2EE Servlets. Internet i jego zastosowania 2 Agenda Overview Servlet Interface Servlet Context Request Response Sample.
Advertisements

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 10 Servlets and Java Server Pages.
7 Copyright © 2005, Oracle. All rights reserved. Maintaining State in J2EE Applications.
4 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: Servlets.
6 Copyright © 2005, Oracle. All rights reserved. Using Advanced Techniques in Servlets.
1 Servlets Based on Notes by Dave Hollinger & Ethan Cerami Also, the Online Java Tutorial by Sun.
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 22 World Wide Web and HTTP.
Introduction to Servlets Based on: Hall, Brown, Core Servlets and JavaServer Pages.
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 and a little bit of Web Services Russell Beale.
An introduction to Java Servlet Programming
The Application Layer Chapter 7. Electronic Mail Architecture and Services The User Agent Message Formats Message Transfer Final Delivery.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 34 Servlets.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 6 Server-side Programming:
Definitions, Definitions, Definitions Lead to Understanding.
Introduction to Servlet & JSP
Session-01. What is a Servlet? Servlet can be described in many ways, depending on the context: 1.Servlet is a technology i.e. used to create web application.
Servlets Compiled by Dr. Billy B. L. Lim. Servlets Servlets are Java programs which are invoked to service client requests on a Web server. Servlets extend.
Servlets. Our Project 3-tier application Develop our own multi-threaded server Socket level communication.
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.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
1 Lecture 10 Server-side Programming: Java Servlets.
Overview A plain HTML document is static A CGI program is executed in real-time, so that it can output dynamic information. CGI (Common Gateway Interface)
CP3024 Lecture 3 Server Side Facilities. Lecture contents  Server side includes  Common gateway interface (CGI)  PHP Hypertext Preprocessor (PHP) pages.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
HTTP client wide area network (Internet) HTTP proxy HTTP server HTTP gateway firewall HTTP tunnel Copyright Springer Verlag Berlin Heidelberg 2004.
Servlets Pranav Maydeo. What is a Servlet ? Servlets are modules of Java code that run in a server application to answer client requests. Servlets are.
CS 493/693: Distributed Systems Programming V. “Juggy” Jagannathan CSEE, West Virginia University March 21, 2005.
Objectives Java Servlet Web Components
CSC 2720 Building Web Applications
COMP 321 Week 7. Overview HTML and HTTP Basics Dynamic Web Content ServletsMVC Tomcat in Eclipse Demonstration Lab 7-1 Introduction.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: HTTP and CGI Fundamentals of Web Programming.
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
Java Servlets & Java Server Pages Lecture July 2013.
Chapter 6 Server-side Programming: Java Servlets
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
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.
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
20-Nov-15introServlets.ppt Intro to servlets. 20-Nov-15introServlets.ppt typical web page – source Hello Hello.
Internet and Intranet Fundamentals
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
Java Servlet API CGI / HTTP Concepts Java Servlet API.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development Session II: Introduction to Server-Side Web Development with Servlets.
Operating Systems Lesson 12. HTTP vs HTML HTML: hypertext markup language ◦ Definitions of tags that are added to Web documents to control their appearance.
1 Java Servlets l Servlets : programs that run within the context of a server, analogous to applets that run within the context of a browser. l Used to.
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.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
Krerk Piromsopa. 1 Department of Computer Engineering. Chulalongkorn University. Web Application Generic Issues.
Introduction to Servlets Allen Day. Notes This is a training NOT a presentation Please ask questions Prerequisites.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
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.
® IBM Software Group © 2007 IBM Corporation Servlet API (Part II)
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 21 Java Servlets Wed. 11/22/00 based on material.
HTTP protocol Java Servlets. HTTP protocol Web system communicates with end-user via HTTP protocol HTTP protocol methods: GET, POST, HEAD, PUT, OPTIONS,
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Introduction to CGI PROG. CGI stands for Common Gateway Interface. CGI is a standard programming interface to Web servers that gives us a way to make.
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.
Speaker Name Speaker Title Speaker Title Oracle Corporation Olivier Le Diouris Principal Product Manager Oracle Corporation Building Servlet and JSP Applications.
Servlet Fudamentals.
Java Servlets By: Tejashri Udavant..
Chapter 26 Servlets.
Objectives In this lesson you will learn about: Need for servlets
Knowledge Byte In this section, you will learn about:
Environment Variables
Introduction to Java Servlets
Presentation transcript:

Copyright © 2002 ProsoftTraining. All rights reserved. Java Servlets

Copyright © 2002 ProsoftTraining. All rights reserved. Lesson 1: Introduction to Java Servlets

Objectives Describe the differences between servlets and other Web application technologies Explain the difference between the GET and POST methods of making an HTTP request Create a simple servlet using GET Create a simple servlet using POST Define a simple deployment descriptor

Introduction to Web Applications Web application technologies –Common Gateway Interface (CGI) –Server extensions –Server-side scripting –JavaServer Pages –Java servlets

Hypertext Transfer Protocol The GET method The POST method Additional methods

Writing a Simple Servlet

Responding to Form Data FormServlet getParameter method Using the POST method

Deployment Descriptors XML files conforming to Sun Microsystems DTD –Describes servlets contained within a Web application

Summary Describe the differences between servlets and other Web application technologies Explain the difference between the GET and POST methods of making an HTTP request Create a simple servlet using GET Create a simple servlet using POST Define a simple deployment descriptor

Copyright © 2002 ProsoftTraining. All rights reserved. Lesson 2: The Servlet Life Cycle

Objectives Describe the servlet life cycle Create init and destroy methods Retrieve servlet initialization parameters Use the SingleThreadModel interface Retrieve CGI environment variables Retrieve and use the ServletContext object Use temporary files

The Multithreaded Model Servlets typically operate in a multithreaded environment –The Web server usually instantiates only one instance of a servlet to serve all clients Deployment descriptors and the multithreaded model

The Single Thread Model The Web server guarantees that no two threads will ever operate concurrently on the same servlet instance To designate servlets to use the single thread model, implement the following interface: –javax.servlet.SingleThreadModel

The init and destroy Methods The init method –Initialization parameters and the deployment descriptor The destroy method

CGI Environment Variables AUTH_TYPE CONTENT_LENGTH CONTENT_TYPE HTTP_ACCEPT HTTP_REFERER HTTP_USER_AGENT PATH_INFO PATH_TRANSLATED QUERY_STRING REMOTE_ADDR REMOTE_HOST REMOTE_USER REQUEST_METHOD SCRIPT_NAME SERVER_NAME SERVER_PROTOCOL SERVER_PORT

The ServletContext Methods for obtaining server information Using temporary files

Summary Describe the servlet life cycle Create init and destroy methods Retrieve servlet initialization parameters Use the SingleThreadModel interface Retrieve CGI environment variables Retrieve and use the ServletContext object Use temporary files

Copyright © 2002 ProsoftTraining. All rights reserved. Lesson 3: Responding to a Request

Objectives Use client-side caching Use client pull to update a client Redirect the client to another URL Use persistent connections Use response status codes Return a file to a client Dynamically generate images

Controlling the Client Using client-side caching Using client pull Redirecting the client

Persistent Connections public class PersistentConnection extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setBufferSize(32 * 1024); resp.setContentType("text/html"); PrintWriter out = resp.getWriter(); // Generate a response }

Status Codes Status code constants sendError method used to set status code

Multimedia Content Returning a file Dynamically generating images

Summary Use client-side caching Use client pull to update a client Redirect the client to another URL Use persistent connections Use response status codes Return a file to a client Dynamically generate images

Copyright © 2002 ProsoftTraining. All rights reserved. Lesson 4: Servlet Sessions

Objectives Track a session using hidden form fields Track a session using URL rewriting Track a session using cookies

Hidden Form Fields Hidden form field named "SID" with an assigned value of " "

URL Rewriting Servlets can build URLS that add information in the form of additional path information

Cookies Small pieces of information transmitted from a Web server to a Web browser Represented in Java using the Cookie class

Summary Track a session using hidden form fields Track a session using URL rewriting Track a session using cookies

Copyright © 2002 ProsoftTraining. All rights reserved. Lesson 5: Authentication and Security

Objectives Authenticate a user using HTTP-based authentication Authenticate a user using a form Use Secure Sockets Layer to improve security

HTTP-Based Authentication Users The deployment descriptor Servlets and authentication

Form Authentication Requires modification of the deployment descriptor –The login-config element must be modified to indicate that form authentication is to be used and to provide the URL for a login page and login error page

Summary Authenticate a user using HTTP-based authentication Authenticate a user using a form Use Secure Sockets Layer to improve security

Copyright © 2002 ProsoftTraining. All rights reserved. Lesson 6: Inter-Servlet Communication

Objectives Share data with another servlet Handle a single request using multiple servlets

Sharing Data Data-sharing methods of the ServletContext interface Sharing data with another ServletContext

Dispatching to Another Servlet The forward method The include method

Summary Share data with another servlet Handle a single request using multiple servlets

Copyright © 2002 ProsoftTraining. All rights reserved. Lesson 7: Building Enterprise Web Applications

Objectives Use JNDI to look up EJBs, resource factories and environment entries Write servlets for use in a distributed environment Use JavaMail to send

Java Servlets and JNDI Referencing EJBs Referencing resource factories Referencing environment entries

Clustering and Java Servlets Clustering styles Developing distributable servlets

JavaMail Add-on API that creates a full-fledged POP/iMAP client –Session class –getDefaultInstance static method

Summary Use JNDI to look up EJBs, resource factories and environment entries Write servlets for use in a distributed environment Use JavaMail to send

Copyright © 2002 ProsoftTraining. All rights reserved. Lesson 8: Internationalization

Objectives Use the Unicode escape sequence to specify special Latin characters Use alternative character sets to generate a non-Latin character response

The Latin Character Set Non-English Latin characters Languages and language codes

Non-Latin Character Sets Arabic Chinese Japanese Korean Russian

Summary Use the Unicode escape sequence to specify special Latin characters Use alternative character sets to generate a non-Latin character response

Java Servlets Introduction to Java Servlets The Servlet Life Cycle Responding to a Request Servlet Sessions Authentication and Security Inter-Servlet Communication Building Enterprise Web Applications Internationalization