How CGI and Java Servlets are Run By David Stein 14 November 2006.

Slides:



Advertisements
Similar presentations
Java Server Pages (JSP)
Advertisements

 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.
Server Side Programming Common Gateway Interface (CGI): Scripts generate Web pages or other files dynamically by processing form data and returning documents.
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.
CSE 190: Internet E-Commerce Lecture 7. HTML Templates Designed to separate server side logic from HTML presentation Key features –Escapes from HTML into.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 34 Servlets.
JSP Java Server Pages Reference:
June 1, 2000 Object Oriented Programming in Java (95-707) Advanced Topics 1 Lecture 10 Object Oriented Programming in Java Advanced Topics Servlets.
Servlets. A form The HTML source Chapter 1 Please enter your name and password then press start Name: Password: In Netbeans you can graphically create.
1 CS6320 – Servlet Structure and Lifecycle L. Grewe.
1 CS6320 – Why Servlets? L. Grewe 2 What is a Servlet? Servlets are Java programs that can be run dynamically from a Web Server Servlets are Java programs.
Servlets Replace Common Gateway Interface Scripts Extend Server Functionality Modules (software components) Like applets to browsers No GUI.
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.
Definition Servlet: Servlet is a java class which extends the functionality of web server by dynamically generating web pages. Web server: It is a server.
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 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.
Servlet and JSP Programming: An Introduction Spiros Papadimitriou
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Server-side Technologies
1 Servlet How can a HTML page, displayed using a browser, cause a program on a server to be executed?
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.
Servlets. - Java technology for Common Gateway Interface (CGI) programming. - It is a Java class that dynamically extends the function of a web server.
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.
Java support for WWW Babak Esfandiari (sources: Qusay Mahmoud, Roger Impey, textbook)
Chapter 5 Java Servlets. Objectives Explain the nature of a servlet and its operation Use the appropriate servlet methods in a web application Code the.
CMPUT 391 – Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems Web based Applications,
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
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.
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
Java Servlets Lec 27. Creating a Simple Web Application in Tomcat.
Chapter 6 Server-side Programming: Java Servlets
20-Nov-15introServlets.ppt Intro to servlets. 20-Nov-15introServlets.ppt typical web page – source Hello Hello.
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.
JavaServer Page by Antonio Ko. Overview ► Introduction ► What is a servlet? ► What can servlets do? ► Servlets Vs JSP ► Syntax ► Samples ► JavaBean ►
Java Servlets and Java Server Pages Norman White Stern School of Business.
Middleware 3/29/2001 Kang, Seungwoo Lee, Jinwon. Description of Topics 1. CGI, Servlets, JSPs 2. Sessions/Cookies 3. Database Connection(JDBC, Connection.
Servlets.
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.
Java Servlets Java Server Pages (JSP)
Java and the Web CSE 3330 Southern Methodist University.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 21 Java Servlets Wed. 11/22/00 based on material.
Java Servlets and Java Server Pages
HTTP protocol Java Servlets. HTTP protocol Web system communicates with end-user via HTTP protocol HTTP protocol methods: GET, POST, HEAD, PUT, OPTIONS,
Introduction To HTML Dr. Magdi AMER. HTML elements.
April 20023CSG11 Electronic Commerce Java (2) John Wordsworth Department of Computer Science The University of Reading Room 129,
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.
1 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
Distributed Web Systems Java Servlets Lecturer Department University.
Introduction to Servlets
Servlet Fudamentals.
Java Servlets By: Tejashri Udavant..
Net-centric Computing
HTTP Servlet Overview Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers. For example, a servlet might.
Servlet.
Chapter 26 Servlets.
Introduction to Servlets
Web Search Interfaces.
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Java Servlets Servlet Overview Servlets and HTML Forms Servlet Basics
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Presentation transcript:

How CGI and Java Servlets are Run By David Stein 14 November 2006

CGI

What is CGI? Common Gateway Interface server side program or script used to process data entered into an online form commonly referred to as a script

What is needed in order to create and run a CGI program? Computer with: 1. Internet access 2. Web browser 3. Text editor Access to a web server Knowledge of HTML and a programming/scripting language

What languages are associated with CGI Any programming language that can be run or executed in a server environment – C – C++ – Visual Basic – PHP – Perl – Java – Etc…

How is a CGI program run? 1. User requests a web page 2. Web server responds with request 3. User enters data into an HTML form and sends it back to the web server HTML form (Get or Post) 4. Server receives the request from the user and processes the form Compiled or Interpreted 5. Server responds with appropriate data to the user

CGI Process Internet HTTP Request HTTP Response Script Processed

Example Form HTTP request for a webpage HTTP Request – Request Line Command, URL ( _form.html), and HTTP version – Request Header Variety of optional info (i.e. web browser and date) – Request Body Information that needs to be sent to the server – Data typed into the form

HTTP Response Response Status – HTTP version #, server, status code (200 or 400), and a response phrase Response Header – Variety of optional info (web server used, date, exact URL of page, etc….) Response Body – Webpage

Processed PHP Script Your Feedback <?php // handle_php.php //This page receives the data from feedback.html. //It will receive: title, name, , response, comments, and submit print "Thank you $title $name for your comments. "; print "You stated that you found this example to be $response and added: $comments"; ?>

Java Servlets

What are Java Servlets? Modules of Java code that run in a server application (similar to an applet on the client side) Counterpart to dynamic web technologies such as PHP, ASP.Net, etc…

Uses of Java Servlets Processing/storage of data submitted by an HTML form Provide dynamic content to a web server Managing of state information on top of stateless HTTP

Java Servlet Process Internet HTTP Request HTTP Response Developer with JSDK Java VM (servlet engine) Client

Example Java Servlet Code import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class HelloClientServlet extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); out.println(" Hello Client! "+ " Hello Client! "); out.close(); } public String getServletInfo() { return "HelloClientServlet 1.0 by Stefan Zeiger"; }

Servlet Output

Servlet Advantages Over CGI Servlet does not run in a separate process – (removes overhead of creating a new process) Servlet stays in memory between requests Servlet can be run in restrictive Sandbox

Sources PHP (Visual Quick Start Guide) – By Larry Ullman essentials essentials fcs/doc/Servlets.html fcs/doc/Servlets.html er.html er.html